Convert Map Server Cache Storage Format (Server)


Converts the storage of a map service cache between the exploded (pre-10.0) format and the compact format. The tool converts the format "in place", meaning it does not make a copy of the existing format. Instead, it creates the new format cache in the same cache folder and deletes the old format.



ConvertMapServerCacheStorageFormat_Server (server_name, object_name, data_frame, {storage_format_type}, {thread_count})
ParameterExplanationData Type

The ArcGIS Server machine hosting the service whose cache format will be changed.


The map service whose cache format will be changed.


The new cache format replaces the old cache format. Make a backup of your cache if you wish to go back to your old format.


The source data frame for the map service.


The storage format to which the new cache will be converted. The tool user interface detects your current cache format and lists the other format as the only option for this parameter. The formats are EXPLODED and COMPACT.


Number of map service instances to use while converting the cache. By default the maximum allowable number of instances will be used (default for an ArcGIS Server service is 2) . If you have more server power, you can raise the maximum allowable number of instances (accessible from the Service Properties dialog box in ArcCatalog, the Catalog window, or Manager), then raise this parameter when you run the tool.


Code Sample

This example uses ConvertMapServerCacheStorageFormat to convert an exploded cache to a compact cache.

# ConvertMapServerCacheStorageFormat example (stand-alone script)

# Name:
# Description: The following stand-alone script demonstrates how to convert map
#               server cache storage format to the alteranate storage format
# Requirements: os, sys, time, traceback modules
# Author: ESRI

# 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, string, datetime, traceback

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

# List of variables for mapservice properties
server = "MyServer"
service = "Rainfall"
dataFrame = ""
threadCount = "2"

currentTime =
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')

# One can leave the variable for storage format marked "COMPACT" to "" (default)

    starttime = time.clock()
    result = arcpy.ConvertMapServerCacheStorageFormat_server (server, service, dataFrame,
                                                     "COMPACT" , threadCount)
    finishtime = time.clock()
    elapsedtime = finishtime - starttime
    #print messages to a file
    while result.status < 4:
    resultValue = result.getMessages()
    report.write ("completed " + str(resultValue))
    print "Converted Map Server Cache Storage format for " + service + " in "
    + str(elapsedtime) + " sec \n on" + arg2 
except Exception, e:
    # If an error occurred, print line number and error message
    tb = sys.exc_info()[2]
    report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
print "Converted Map Server Cache Storage format "


This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes