Error processing SSI file
LEADTOOLS Caching (Leadtools.Caching assembly)

Show in webframe

FileCache Class






Members 
Represents LEADTOOLS support for a file cache.
Object Model
Syntax
[DefaultMemberAttribute("Item")]
public class FileCache : ObjectCache 
'Declaration
 
<DefaultMemberAttribute("Item")>
Public Class FileCache 
   Inherits ObjectCache
'Usage
 
Dim instance As FileCache
public class FileCache extends ObjectCache
            
[DefaultMemberAttribute("Item")]
public ref class FileCache : public ObjectCache 
Remarks

FileCache implements ObjectCache and is the LEADTOOLS implementation of a file cache. It is used by the LEADTOOLS Documents classes when caching is required to store the document data.

To use a FileCache, set the CacheDirectory property to a valid directory in your system or in a network share. then use the various methods and properties to add and retrieve cache items with optional expiration policies. The cache will store the items and their policies into disk using serialization and retrieve them using de-serialization.

Since the cache uses the global file system, it can be re-used after the application is terminated. FileCache does not store any state data and all the items are stored in disk. For instance, the LEADTOOLS Documents Web Service creates an instance of FileCache with every method call. All instances point to the same CacheDirectory and can therefore use the same items added in previous calls. The cache is thread and process safe.

FileCache provide support for regions which is used to group cache items belonging to the same logical object. These regions are created as sub-directories in the cache directory on disk. LEADTOOLS Documents classes uses the unique document identifier as the region name and hence can delete all the items belonging to a single document by deleting the region.

Items are purged from the cache if they have an absolute or sliding expiration policy. This is done when the item is accessed (it will be deleted if expired) or by the user by using CheckPolicy or CheckPolicies.

Since cache items that are not used will stay on disk, it is preferable to create a process for purging expired policies manually. This can be done by calling CheckPolicies which will check the whole cache and delete any items that are expired.

GetCacheFilePath returns the physical path of any item currently stored in the cache. This gives the user the ability to read the data of the item directly or pass the file to another part of the system that may require a physical file on disk. The GetStream method can then be used to obtain a direct input or output stream to file.

GetCacheUrl returns a URI to any item currently stored in the cache. CacheVirtualDirectory must be setup to use this method. Obtaining a URI to a cache item can be useful in a Web application if the client code is JavaScript for example.

This cache implementation also supports data items with values set to null. Thus it is always preferable to use Contains or GetCacheItem(String,String) instead of relying to Get(String,String) and checking for null.

The ObjectCache.CacheItemExpiring and ObjectCache.CacheItemExpired events occur when an item is expired and is about to be removed from the cache.

Use GetStatistics to get the number of regions, items and expired items currently in the cache.

Example

For an example, refer to Leadtools.Documents.DocumentFactory.

Requirements

Target Platforms

See Also

Reference

FileCache Members
Leadtools.Caching Namespace

Error processing SSI file
Leadtools.Caching requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features