Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Documents Namespace > DocumentFactory Class : Cache Property |
public static FileCache Cache {get; set;}
'Declaration
Public Shared Property Cache As FileCache
'Usage
Dim value As FileCache DocumentFactory.Cache = value value = DocumentFactory.Cache
public static ObjectCache getCache() public void sbjectCache getCache(static value)
public: static property FileCache^ Cache { FileCache^ get(); void set ( FileCache^ value); }
A large portion of the Documents class library requires the use of a cache system. This includes almost all of 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 Documents 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 Documents Web Service requires the use of a cache. Web methods are sessionless 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.
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 Document classes will use this global value for all the caching needs.
Setting up a FileCache object is easy. The only input required is the path to a directory on disk or network share where the cache items are stored.
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.
One such example is the LEADTOOLS Document Viewer Demo. It obtains a temporary folder and set it as the cache directory to use (FileCache.CacheDirectory). It then uses default CacheItemPolicy objects that do not expire and the document parts are cached and used. The value of AutoSaveToCache is set to false and each document will delete its cache entry when it is disposed and no longer used.
The application requires the document state to persist between sessions.
One such example is the LEADTOOLS Documents 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.
For an example, refer to DocumentFactory