清除工作空间缓存 (Data Management)

许可等级:BasicStandardAdvanced

摘要

清除 ArcSDE 工作空间缓存中的全部 ArcSDE 工作空间。

用法

语法

ClearWorkspaceCache_management ({in_data})
参数说明数据类型
in_data
(可选)

ArcSDE 数据库连接文件代表要从 ArcSDE 工作空间缓存中移除的 ArcSDE 工作空间。指定在运行地理处理工具时使用的 ArcSDE 连接路径,以从缓存中移除特定的 ArcSDE 工作空间。不给出任何输入数据将会清除该缓存中的所有 ArcSDE 工作空间。

Data Element; Layer

代码实例

ClearWorkspaceCache 示例(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用 ClearWorkspaceCache 函数。

import arcpy
from arcpy import env
env.workspace = "c:/connectionFiles/Connection to gpserver.sde"
arcpy.ClearWorkspaceCache_management()
清除工作空间缓存示例

示例展示了如何通过清除 ArcSDE 工作空间缓存断开与 ArcSDE 的连接。这里展示了两种方法。1. 通过指定连接文件名称来断开特定连接。2. 通过将 ArcSDE 连接文件参数留空可断开所有连接。

# Name: ClearWorkspaceCache_Example.py
# Description: Two examples: 1. Remove the specified ArcSDE workspace from the workspace cache, 
#                               terminating the connection to ArcSDE from this client
#                            2. Remove many ArcSDE workspaces from the workspace cache, 
#                               terminating the connection to ArcSDE from this client for each workspace.

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "Database Connections\Connection to gpserver.sde" # Creates a connection to ArcSDE
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print str(fcList) + "\n"
env.workspace = "" # Release hold on ArcSDE 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
env.workspace = "Database Connections\Connection to gpServer.sde" # Creates a connection to ArcSDE
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print str(fcList) + "\n"

# Connection 2
env.workspace = "Database Connections\Connection to ProductionServer.sde" # Creates a connection to ArcSDE
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print str(fcList) + "\n"

# Connection 3
env.workspace = "Database Connections\Connection to TestServer.sde" # Creates a connection to ArcSDE
fcList = arcpy.ListFeatureClasses() # Show that we are connected
print str(fcList) + "\n"
env.workspace = "" # Release hold on ArcSDE workspace created in previous steps.

# Execute the Clear Workspace Cache tool
arcpy.ClearWorkspaceCache_management() # If you do not specify a connection, all ArcSDE workspaces will be removed from the Cache
print arcpy.GetMessages()

环境

相关主题

许可信息

ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014