←Select platform

Cache Property

Summary

The LEADTOOLS ObjectCache object responsible for managing cache items and expiration policies.

Syntax
C#
VB
C++
Java
public static ObjectCache Cache { get; set; } 
Public Shared Property Cache() As ObjectCache 
   Get 
   Set 
public:  
   static property ObjectCache^ Cache 
   { 
      ObjectCache^ get() 
      void set(ObjectCache^ value) 
   } 
public static ObjectCache getCache() 
public void ObjectCache getCache(static value) 

Property Value

The cache object responsible for managing cache items and expiration policies. Default value is null.

Remarks

Note: This property will be deprecated in the next version of LEADTOOLS, instead, initialize a cache object and use it directly with the various DocumentFactory methods that require it.

A large portion of the Documents class library requires the use of a cache system. This includes almost all the write support. Documents can contain large number of pages and huge amount of data. Storing all this data in the physical memory is not feasible in most situations. Therefore, the Document library was designed to use an external caching system to store the modified parts of the document.

Using a large will also increase the performance when getting page data such as an image or text. The result will be parsed once from the physical file on disk, processed and then stored in the cache. Subsequent calls to the same data will simply retrieve it from the cache without any extra processing.

The LEADTOOLS Document Web Service requires the use of a cache. Web methods are session-less by nature and with cache support, the service can use SaveToCache and LoadFromCache to save/load the document state in-between calls without the need for session state. DocumentFactory can be used to remove a document from the cache when it is no longer needed.

In almost all cases, the cache object is initialized and set into Cache at the start of the application and then never touched. The DocumentFactory and LEADDocument classes will use this global value for all the caching needs.

The default LEADTOOLS implementation of ObjectCache is FileCache object and setting it up is easy. The only input required is the path to a directory on disk or network share where the cache items are stored.

Refer to Document Toolkit and Caching for more information on how the cache is used with the LEADTOOLS Document library and how to set up optional custom cache provider.

Generally, the cache is used in two ways depending on the type of the application:

  • The application uses the cache to speed up getting data from existing documents or to create new documents. The data is not shared with other applications, nor is required to persist between sessions. An example is the LEADTOOLS Document Viewer Demo. It obtains a temporary folder and sets it as the cache directory to use for CacheDirectory objects that do not expire, and the document parts are cached and used. The value of AutoSaveToCache is set to false: each document will delete its own cache entry when it is disposed and no longer needed.

  • The application requires the document state to persist between sessions. An example is the LEADTOOLS Document Web Service. It contains a global cache directory stored in the web.config file. The cache is constructed with each session (web method) by setting the same value in CacheDirectory. When a document is loaded, it is saved in the cache using SaveToCache before the web method returns, and then re-loaded when a new session (web method) starts using LoadFromCache. These types of applications usually store a policy setting in the web.config as well. This will control how long to store items in the cache before they expire. The FileCache.CheckPolicies method can be used by an external process in the application to periodically run and purge expired items.

Example

For an example, refer to DocumentFactory

Requirements

Target Platforms

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly