|
ASPCache Object Reference |
|
See Also: |
The ASPCache™ object is a high-performance, thread-safe, collection component designed to make it easy to cache information in Active Server Pages.
"ASPCache.1"
"ASPCache"
CLSID_ASPCache, found in <ASPCache install dir>\include\ASPCache.h
| Item | Variant (r/w) | Returns/sets an item in the cache. |
| Count | Integer (r) | The number of items in the cache. |
| Enabled | Boolean (r/w) | Set to false to disable caching. |
| MaxSize | Integer (r/w) | Set/retrieve the max number of items to hold in the cache. |
| FlushEnabled | Boolean (r/w) | Set to true to enable background cleanup of rarely used items and expired items. |
| FlushTimeout | Integer (r/w) | Set/retrieve the time (in milliseconds) an item must be unused before it is flushed from the cache. |
| FlushInterval | Integer (r/w) | Set/retrieve the period (in milliseconds) between background cleanup operations. |
| Add() | Add an item (key, value pair) to the cache. |
| Exists() | Return true if there is an item in the cache with this key or handle. |
| KeyOf() | Return the key for this handle. |
| HandleOf() | Return the handle for an item in the cache. |
| Hits() | Return the number of hits on an item in the cache. |
| Expiration() | Return the period of time (in milliseconds) before an item expires. |
| SetExpiration() | Set the period of time (in milliseconds) for an item to live before it expires. |
| TimeInCache() | Return the time (in milliseconds) that has elapsed since an item was added to the cache. |
| TimeSinceLastUse() | Return the time (in milliseconds) that has elapsed since an item was last accessed. |
| Remove() | Remove an item from the cache. |
| RemoveAll() | Empty the cache. |
| Flush() | Initiate a background flush operation. This removes items that have not been used in a while or have expired. |
| WriteFile() | Write the contents of a file to the ASP Response object. Use the cache to retrieve and store the file's contents. |
ASPCache is a high-performance, thread-safe, collection component designed to make it easy to cache information in Active Server Pages. For more information on how to use ASPCache, see Introduction to ASPCache.
To give an ASPCache object application scope, instantiate it in global.asa:
REM *** global.asa ***
<OBJECT RUNAT=Server SCOPE=Application ID=Cache PROGID=ASPCache></OBJECT>
After an ASPCache object is instantiated with application scope, it can be accessed from any ASP page.
Items can be added and removed using standard collection syntax:
<%
' *** test_cache.asp ***
' Store a value in the Cache object
Cache("key1") = value1
' Retrieve a value from the Cache object
value2 = Cache("key2")
%>
Use VBScript for ... each to enumerate handles to
all objects in the collection:
' Enumerate all items in the Cache
Dim h, sKey, vValue
For Each h in Cache
sKey =
Cache.KeyOf(h)
vValue =
Cache(h)
Next
To enumerate the ASPCache object in JScript, use the JScript Enumerator
object:
var e, h, sKey, vValue;
e = new Enumerator(Cache);
for (;!e.atEnd();e.moveNext())
{
h = e.item();
sKey = Cache.KeyOf(h);
vValue = Cache(h);
}