APGen Documentation Previous Topic: ASPCache Object Next Topic: ASPCache.Count Parent Topic: ASPCache Object    ASPCache Object
ASPCache.Item
See Also:

Retrieves or sets an item in the cache. 

Syntax

VBScript:

[Set] vValue = Cache.Item( key )
or
[Set] vValue = Cache( key )

JScript:

vValue = Cache.Item( key );
or
vValue = Cache( key );

Object

Cache An ASPCache object.

Parameters

key A string key or item handle.

Return Value

vValue The object stored in the cache at location key .

Notes

For a description of the collection functionality exposed by ASPCache, see Collection Functionality.

The Item property can be used to read or write an item in the collection.  Lookup by string key is case-insensitive and very high performance - our algorithm outperforms all hash tables we have tested.  Lookup by handle is even faster, it is O(1) - we recommend using handles if the same item will be accessed several times in a page.

If an item that does not exist is attempted to be read from the cache, an empty value is returned.

If an item is written to the cache using a string key, and the string key is not present, the item is added to the cache.  If an item is written to the cache using a handle, and the handle does not exist, an error is raised.

This code snippet demonstrates how to store data in an ASPCache object:

' Store a string in the Cache
Cache("key1") = "Value1"

' Store an object in the Cache
' Preferably only store "Both" threaded objects in an ASPCache.
Dim oXmlDoc
Set oXmlDoc = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
' ...
Cache("xmlDoc") = oXmlDoc

This code snippet demonstrates how to read data from an ASPCache object:

' Read a string from the Cache
Dim sValue
sValue = Cache("key1")

' Retrieve an object from the Cache
Set oXmlDoc = Cache("xmlDoc")