Chilkat VB.NET Cache Class Reference
Cache
Properties
LastErrorHtml As String (ReadOnly)
Error information in HTML format for the last method called.
LastErrorText As String (ReadOnly)
Error information in plain-text format for the last method called.
LastErrorXml As String (ReadOnly)
Error information in XML format for the last method called.
LastEtagFetched As String (ReadOnly)
The ETag of the last item fetched from cache.
LastExpirationFetched As Date (ReadOnly)
Expiration date/time of the last item fetched from cache.
LastHitExpired As Boolean (ReadOnly)
true if the LastExpirationFetched is before the current date/time. Otherwise false.
LastKeyFetched As String (ReadOnly)
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.)
Level As Integer
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.
NumRoots As Integer (ReadOnly)
The number of root directories composing the cache. A typical multi-root cache would place each root on a separate hard drive.
Methods
Sub AddRoot(ByVal path As String)
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".
Function DeleteAll() As Integer
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.
Function DeleteAllExpired() As Integer
Deletes all expired items from the cache.
Returns the number of items (i.e. cache files) deleted.
Function DeleteFromCache(ByVal key As String) As Boolean
Deletes a single item from the disk cache. Returns false if the item exists in cache but could not be deleted. Otherwise returns true.
Function DeleteOlder(ByVal dt As Date) As Integer
Deletes all items older than a specified date/time.
Returns the number of items (i.e. cache files) deleted.
Function FetchFromCache(ByVal key As String) As Byte()
Fetches an item from cache. Returns Nothing on failure
Function GetEtag(ByVal key As String) As String
Returns the eTag for an item in the cache. Returns Nothing on failure
Function GetExpiration(ByVal key As String) As Date
Returns the expire date/time for an item in the cache.
Function GetFilename(ByVal key As String) As String
To be documented soon. Returns Nothing on failure
Function GetRoot(ByVal index As Integer) As String
Returns the directory path of the Nth cache root. (Indexing begins at 0.) Returns Nothing on failure
Function IsCached(ByVal key As String) As Boolean
Returns true if the item is found in the cache, otherwise returns false.
Function SaveLastError(ByVal filename As String) As Boolean
Saves the last error information to an XML formatted file.
Function SaveToCache(ByVal key As String, ByVal expireDateTime As Date, ByVal eTag As String, ByVal itemData As Byte()) As Boolean
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.
Function SaveToCacheNoExpire(ByVal key As String, ByVal eTag As String, ByVal itemData As Byte()) As Boolean
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.
Function UpdateExpiration(ByVal key As String, ByVal expireDateTime As Date) As Boolean
Updates the expire date/time for a cached item. Returns true for success, false for failure.
|