Share via


Code to Manipulate an LRUCache Object

The following example code shows how to use the LRUCache object.

' Declare variables to be used.
Dim oLRUCache, oDict, oNewDict, NumVal

' Create an instance of an LRU cache.
Set oLRUCache = CreateObject("Commerce.LRUCache")

' Set the max cache size to 100 items. 
oLRUCache.SetSize 100

' Create an object to store.
Set oDict = CreateObject("Commerce.Dictionary")
oDict("Test") = "This is a test."

' Store the Dictionary object.
oLRUCache.Insert "DictObject", oDict

' Store the number 10.
oLRUCache.Insert "Number", 10

' Lookup the stored Dictionary object using method LookupObject.
Dim oNewDict
Set oNewDict = oLRUCache.LookupObject "DictObject"

' Lookup the stored number using method Lookup.
Dim NumVal
NumVal = oLRUCache.Lookup "Number"

' Remove all items from the cache.
oLRUCache.FlushAll

' Display the results, which will be:
' This is a test.
' 10
Response.Write "Dictionary data from cache: " & oDict.Test & "<BR>"
Response.Write "Number stored in cache: " & NumVal & "<BR>"

Copyright © 2005 Microsoft Corporation.
All rights reserved.