|
ASPCache Object |
|
See Also: |
Adds an item to the cache.
VBScript:
JScript:
| Cache | An ASPCache object. |
| key | A string key used to store and lookup the new item. |
| value | The value to be stored in the cache. This parameter is a Variant, so any data type may be used. |
| expireTime | Optional. The expiration period for this item. If no value is specified, the item will not expire. |
| bAdded | True if the item was successfully added. False if the key already exists in the cache. |
The Add method will fail if the specified key already exists in the cache. If you
want to add or overwrite an item regardless of whether it is already present, use the Item property.
This example overwrites an existing item in the cache if it can't be added. One reason you might want to do this is to avoid overwriting the item's expiration period.
' Assume these variables are already initialized
Dim sKey,
vValue, tExpire
' Add the item to the cache
Dim bAdded
bAdded = Cache.Add( sKey, vValue, tExpire )
' If the
item could not be added, it already exists
If (Not bAdded)
Then
' Overwrite the
value
Cache( sKey ) = vValue
End If