Clear Workspace Cache (Data Management)

Summary

Clears information about a workspace that has been cached in memory.

Note:
Workspace caching is used by the geoprocessing framework to improve performance when running script tools or repeated processes. The workspace cache may hold a schema lock for a given workspace, and the cache can be cleared to allow other processes or functions to proceed.

Usage

  • The single input parameter is optional. If you run the tool without specifying a workspace, all contents in the workspace cache will be cleared. To remove cached information about a specific workspace, use that geodatabase, folder, or .sde connection file as input.

  • This tool can be used to help disconnect idle enterprise geodatabase connections in a long-running application.

  • To clear the workspace cache in a Python script, use this tool as the final call in the script. Use the Python del statement to delete all references to objects or variables that may be pointing to the workspace before calling this tool. If the script uses both ArcPy commands and other Python file and folder management commands, schema locks held by the workspace cache may prevent other Python commands from running successfully. Clearing the workspace cache enables these functions that delete or modify files or folders to succeed and not be blocked by schema locks.

  • The first ten workspaces used in an ArcGIS Pro or a stand-alone Python process will be included in the workspace cache. Additional workspaces used in the same process will not be cached.

  • Note:
    Clearing an enterprise geodatabase workspace from the workspace cache does not guarantee that the connection to the enterprise geodatabase server will be disconnected. It will only ensure that the ArcGIS system no longer has any hold on the enterprise geodatabase workspace that has been cleared. If any other process has references to this enterprise geodatabase workspace, the connection will be maintained.

Parameters

LabelExplanationData Type
Input Workspace
(Optional)

The geodatabase, .sde connection file, or folder path representing the workspace that will be removed from the workspace cache. If no value is specified, all contents of the workspace cache will be cleared.

Data Element; Layer

Derived Output

LabelExplanationData Type
Operation succeeded

Whether the operation was successful.

Boolean

arcpy.management.ClearWorkspaceCache({in_data})
NameExplanationData Type
in_data
(Optional)

The geodatabase, .sde connection file, or folder path representing the workspace that will be removed from the workspace cache. If no value is specified, all contents of the workspace cache will be cleared.

Data Element; Layer

Derived Output

NameExplanationData Type
out_results

Whether the operation was successful.

Boolean

Code sample

ClearWorkspaceCache example (Python window)

The following Python window script demonstrates how to use the ClearWorkspaceCache function in immediate mode.

import arcpy
arcpy.env.workspace = "c:/connectionFiles/SQL Server.sde"
arcpy.management.ClearWorkspaceCache()

Environments

This tool does not use any geoprocessing environments.

Related topics