删除地图服务器缓存 (服务器)

描述

删除现有地图影像图层缓存(包括磁盘上的所有关联文件)。

使用方法

  • 由于这是一种不可恢复的操作,因此只有确定不再使用缓存时,方可执行此项操作。如果要删除切片但保留缓存文件夹结构和切片方案,请使用管理地图服务器缓存切片工具,并将更新模式设置为 DELETE_TILES

  • 此工具运行后,将重新启动服务。

语法

DeleteMapServerCache(input_service, {num_of_caching_service_instances})
参数说明数据类型
input_service

待删除缓存切片所属的地图影像图层。

Image Service; MapServer
num_of_caching_service_instances
(可选)

定义用于更新/生成切片的实例数。该参数的值将设置为无限 (-1),且无法进行修改。

Long

派生输出

名称说明数据类型
out_job_url

输出 URL。

字符串

代码示例

DeleteMapServerCache 示例(独立脚本)

在本例中,将使用 DeleteMapServerCache 删除名为 Rainfall 的地图服务的一个缓存。

# Name: DeleteMapServerCache.py
# Description: The following stand-alone script demonstrates how to delete map server cache
#              tiles if the corresponding cache schema or tiles has been created
# Requirements: os, sys, time & traceback modules

# Any line that begins with a pound sign is a comment and will not be executed
# Empty quotes take the default value.
# To accept arguments from the command line replace values of variables to
#                                                           "sys.argv[]"

# Import system modules
import arcpy
from arcpy import env
import os, sys, time, datetime, traceback, string

# Set environment settings
env.workspace = "C:/data"

# List of variables for mapservice properties
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
numOfCachingServiceInstances = 2


currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = 'C:/data/report_%s.txt' % arg1

# print results of the script to a report
report = open (file,'w')

# To Recreate all the tiles for the default number of scales generated
try:
    starttime = time.clock()
    result = arcpy.DeleteMapServerCache_server(inputService,
                                               numOfCachingServiceInstances)
    finishtime = time.clock()
    elapsedtime = finishtime - starttime

    #print messages to a file
    while result.status < 4:
        time.sleep(0.2)
    resultValue = result.getMessages()
    report.write ("completed " + str(resultValue))

    print("Deleted cache tiles & schema for mapservice " + serviceName + \
        "\n  in " + str(elapsedtime) + " sec \n on " + arg2)

except Exception as e:
    # If an error occurred, print line number and error message
    tb = sys.exc_info()[2]
    report.write("Failed at \n" "Line %i" % tb.tb_lineno)
    report.write(str(e))


print("Deleted Map server Cache Tiles ")

report.close()

环境

此工具不使用任何地理处理环境。

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题