Persisting cache information for use in dynamic display


This document discusses cache and how to go about managing the cache for best performance while using dynamic display.

Caching in Dynamic Display

Dynamic display has the capability to reuse the cache for non-dynamic layers. The cache structure for dynamic display is similar to the ArcGIS Server cache structure. In general, Cache information for non-dynamic layer is generated by a background thread. During navigation, if the cache is not available for that area, the background thread will try to create it, which leads to CPU usage. To improve the performance, there are two options to persist the cache information in dynamic display. One is to save the layers as layer files or save the maps as mxds; and the other way is to programmatically connect given layers to the existing caches with IDynamicCacheLayeManager interface.

Save the layers as layer files or save the maps as mxds

Make sure to enable the dynamic map first, then save the layers as layer files or save the maps as mxds. In this way, the existing cache information will be reused during the navigation.
As a fact, Layer files and MXD files will persist the cache information as long as they are saved while in dynamic mode. In other words, the way to persist the cache is to save a MXD or layers while dynamic display is enabled. The next time when dynamic display is enabled on the same session or on a different session, dynamic display will identify the existing cache and then make use of it.
Keep in mind, the cache information is not based on one map scale but a range of map scales. Once an area in the map is visited (zooming/roaming), the cache information will be generated for that area (on a background thread). When you revisit the same area next time, dynamic display would know where the cache is and reuse that cache for the non-dynamic layers.
If you know the area and map scale you will visit ahead, at one session of your mapping application, you could pre-cook caches by zoom in/ roaming to the area and then save the mxd file, be sure under dynamic mode though. Those caches will be reused, without having to use any CPU, when you perform the navigation on the same map on the consequent sessions.

Connect given layers to existing caches

Dynamic display is recommended for use when moving objects or maps on the screen, when object labels are dynamic and change rapidly, or when using a low-end computer and you want to maximize panning and zooming performance by using precooked data. For example, dynamic display is useful if you receive a dynamic feed from a Global Positioning System (GPS) unit on an object, such as a series of distribution trucks. Events can be fired off if the truck becomes troubled or is within a certain distance of an accident. The route can be recalculated and a message can be sent to the driver and a new time estimate can be relayed to the receiver of the goods. For more information, see Best practices for using dynamic display. As mentioned above, cache information for non-dynamic layers could be generated automatically when dynamic display is enabled. It also could be generated programmatically by IDynamicCacheLayerManager.Generate method (set the link to the interface please). By default, Cache information is saved to the Temp directory of the User Profile in either way. With IDynamicCacheLayerManager, however, you could define your own cache directory when generating the cache.
The cache manager must be initialized with the given map and layer in order to use any methods and properties on IDynamicCacheLayerManager interface.
In addition, cache information can be moved or copied to different locations. Then make a connection between the given layer and the existing cache in the new locationthrough the IDynamicCacheLayerManager.Connect method can occur. In this way, the cache information can be reused on the same machine or on a different machine as long as the data location (path) is not changed. In order to connect to an existing cache and initialize the cache manager with the given map and layer, the folder name must be known. The folder name is composed of the layer name together with a global unique identifier assigned by the dynamic display. You can get the folder name from property IDynamicCacheLayerManager.CacheFolder.
As a fact, the Connect method checks the following conditions before making a connection to the cache:
  • The cache structure matches the input layer.
  • Spatial reference of the target cache matches the one of the map.
  • The compression format of the cache matches the one set for the layer.
  • Should the input layer have a reference scale, then it matches the one set to the cache.
  • Renderers and labels are identical.
In conclusion, the cache information can be reused in dynamic display to improve the performance. A cache can be pre-generated by enabling dynamic mode or using IDynamicCacheLayerManager interface, the cache can be persisted with Layer files or mxds, and the cache can be relocated to then make a connection between the cache and the layer.