摘要
清除企业级地理数据库工作空间缓存中的全部企业级地理数据库工作空间。
用法
此工具仅适用于企业级地理数据库工作空间。
在长时间运行的应用程序中,可以使用此工具断开空闲的企业级地理数据库连接。
如果运行此工具时未指定输入数据元素,则将清除企业级地理数据库工作空间缓存中所有的企业级地理数据库工作空间。若要清除特定的企业级地理数据库工作空间,可指定与要清除的工作空间关联的特定 .sde 文件。
语法
ClearWorkspaceCache_management ({in_data})
参数 | 说明 | 数据类型 |
in_data (可选) | 企业级地理数据库连接文件代表要从缓存中移除的企业级地理数据库工作空间。指定在运行地理处理工具时使用的企业级地理数据库连接路径,以从缓存中移除特定的企业级地理数据库工作空间。不给出任何输入数据将会清除该缓存中的所有企业级地理数据库工作空间。 | Data Element; Layer |
代码示例
ClearWorkspaceCache 示例(Python 窗口)
以下 Python 窗口脚本演示了如何在即时模式下使用 ClearWorkspaceCache 函数。
import arcpy
arcpy.env.workspace = "c:/connectionFiles/Connection to gpserver.sde"
arcpy.ClearWorkspaceCache_management()
清除工作空间缓存示例
示例展示了如何通过清除企业级地理数据库工作空间缓存断开与企业级地理数据库的连接。这里展示了两种方法。1. 通过指定连接文件名称来断开特定连接。2. 通过将企业级地理数据库连接文件参数留空可断开所有连接。
# Name: ClearWorkspaceCache_Example.py
# Description: Two examples: 1. Remove the specified enterprise geodatabase workspace from the workspace cache,
# terminating the connection to enterprise geodatabase from this client
# 2. Remove many enterprise geodatabase workspaces from the workspace cache,
# terminating the connection to enterprise geodatabase from this client for each workspace.
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "Database Connections\Connection to gpserver.sde" # Creates a connection to enterprise geodatabase
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print(str(fcList) + "\n")
arcpy.env.workspace = "" # Release hold on enterprise geodatabase workspace created in previous step.
# Execute the Clear Workspace Cache tool
arcpy.ClearWorkspaceCache_management("Database Connections\Connection to gpserver.sde")
print(arcpy.GetMessages() + "\n")
# Clear the Workspace Cache of multiple connections
# Set environment settings
# Connection 1
arcpy.env.workspace = "Database Connections\Connection to gpServer.sde" # Creates a connection to enterprise geodatabase
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print(str(fcList) + "\n")
# Connection 2
arcpy.env.workspace = "Database Connections\Connection to ProductionServer.sde" # Creates a connection to enterprise geodatabase
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print(str(fcList) + "\n")
# Connection 3
arcpy.env.workspace = "Database Connections\Connection to TestServer.sde" # Creates a connection to enterprise geodatabase
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print(str(fcList) + "\n")
arcpy.env.workspace = "" # Release hold on enterprise geodatabase workspace created in previous steps.
# Execute the Clear Workspace Cache tool
arcpy.ClearWorkspaceCache_management() # If you do not specify a connection, all enterprise geodatabase workspaces will be removed from the Cache
print(arcpy.GetMessages())
环境
许可信息
- ArcGIS Desktop Basic: 是
- ArcGIS Desktop Standard: 是
- ArcGIS Desktop Advanced: 是