Chilkat C# Cache Class Reference
Cache
Properties
public string LastErrorHtml {get; }
Error information in HTML format for the last method called.
public string LastErrorText {get; }
Error information in plain-text format for the last method called.
public string LastErrorXml {get; }
Error information in XML format for the last method called.
public string LastEtagFetched {get; }
The ETag of the last item fetched from cache.
public DateTime LastExpirationFetched {get; }
Expiration date/time of the last item fetched from cache.
public bool LastHitExpired {get; }
true if the LastExpirationFetched is before the current date/time. Otherwise false.
public string LastKeyFetched {get; }
The key of the last item fetched from cache. (For web pages, the key is typically the canonicalized URL. Otherwise, the key is a unique identifer used to access the cached item.)
public int Level {get; set; }
The number of directory levels in the cache. Possible values are:
0: All cache files are in a single directory (the cache root).
1: Cache files are located in 256 sub-directories numbered 0 .. 255 directly under the cache root.
2: There are two levels of sub-directories under the cache root. The 1st level has 256 sub-directories numbered 0 .. 255 directly under the cache root. The 2nd level allows for up to 256 sub-directories (0..255) under each level-1 directory. Cache files are stored in the leaf directories.
public int NumRoots {get; }
The number of root directories composing the cache. A typical multi-root cache would place each root on a separate hard drive.
Methods
public void AddRoot(string path);
Must be called once for each cache root. For example, if the cache is spread across D:\cacheRoot, E:\cacheRoot, and F:\cacheRoot, an application would setup the cache object by calling AddRoot three times -- once with "D:\cacheRoot", once with "E:\cacheRoot", and once with "F:\cacheRoot".
public int DeleteAll();
Deletes all items in the cache. This method completely clears the cache. All files in the cache are deleted. (If the cache is multi-level, existing sub-directories are not deleted.)
Returns the number of items (i.e. cache files) deleted.
public int DeleteAllExpired();
Deletes all expired items from the cache.
Returns the number of items (i.e. cache files) deleted.
public bool DeleteFromCache(string key);
Deletes a single item from the disk cache. Returns false if the item exists in cache but could not be deleted. Otherwise returns true.
public int DeleteOlder(DateTime dt);
Deletes all items older than a specified date/time.
Returns the number of items (i.e. cache files) deleted.
public byte[] FetchFromCache(string key);
Fetches an item from cache. Returns null on failure
public string GetEtag(string key);
Returns the eTag for an item in the cache. Returns a null on failure
public DateTime GetExpiration(string key);
Returns the expire date/time for an item in the cache.
public string GetFilename(string key);
To be documented soon. Returns a null on failure
public string GetRoot(int index);
Returns the directory path of the Nth cache root. (Indexing begins at 0.) Returns a null on failure
public bool IsCached(string key);
Returns true if the item is found in the cache, otherwise returns false.
public bool SaveLastError(string filename);
Saves the last error information to an XML formatted file.
public bool SaveToCache(string key, DateTime expireDateTime, string eTag, byte[] itemData);
Inserts or replaces an item in the cache. The eTag is optional and may be set to a zero-length string. Applications may use it as a place to save additional information about the cached item. The Chilkat HTTP component, when caching a page, writes the eTag (entity-tag) from the HTTP response header to this field. Returns true for success, false for failure.
public bool SaveToCacheNoExpire(string key, string eTag, byte[] itemData);
Inserts or replaces an item in the cache. The cached item will have no expiration. The eTag is optional and may be set to a zero-length string. Applications may use it as a place to save additional information about the cached item. Returns true for success, false for failure.
public bool UpdateExpiration(string key, DateTime expireDateTime);
Updates the expire date/time for a cached item. Returns true for success, false for failure.
|