Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

LRUCache Object [C++]

Commerce Server 2002

Use this object to support the creation, storage, and retrieval of name/value pairs, referred to as elements, from a cache in memory. The LRUCache object functions similarly to the Dictionary object, except that it only stores a limited number of elements, and internally ranks them according to use. When the cache is full and a new element needs to be added, the least recently used element is removed from the cache to make room for the new element.

ProgID:  Commerce.LRUCache (Externally creatable)
COM Class Name:  LRUCache
Type Library Name:  Microsoft Commerce 2002 Cache Manager Type Library
DLL Name:  mscscache.dll
Threading Model:  Both
[C++]
COM Interface Name:  ILRUCache
Interface ID Constant:  IID_ILRUCache
Header File:  cacheint.h, mspu_guids.h
[C++]

In C++, use the ILRUCache interface to access the methods of the LRUCache object.

Because this object is primarily intended for use within ASP script, access from C++ will not be common.

Methods

[C++]
MethodDescription
FlushRemoves an element from the cache.
FlushAllRemoves all elements from the cache.
InsertInserts an element into the cache.
LookupReturns the value of an element in the cache when given the name of the element.
LookupObjectReturns an object in the cache when given the name of the object.
SetSizeSets the maximum size of the cache.
[Visual Basic]
MethodDescription
FlushRemoves an element from the cache.
FlushAllRemoves all elements from the cache.
InsertInserts an element into the cache.
LookupReturns the value of an element in the cache when given the name of the element.
LookupObjectReturns an object in the cache when given the name of the object.
SetSizeSets the maximum size of the cache.

Remarks

The LRUCache object is typically created by the CacheManager object rather than directly from an ASP script. It is configured through the Cachemanager.LoaderConfig property. This is done by configuring a CacheManager cache with a LoaderProgID of Commerce.LRUCacheFlush and by setting the LoaderConfig dictionary properties as shown in the table below. The configuration parameters are contained in a Dictionary object.

The following table shows the keys in the dictionary containing the configuration parameters.

KeyDefinition
CacheSizeSpecifies the size of the cache. A value of –1 will result in the default value of 1000 items being used.
ConnectionStringThe connection string to the database where the LRUCacheFlush object should register the cache.
TableNameThe name of the table where the LRUCacheFlush object should register the cache.
AppUrlThe fully qualified URL of the Commerce Server application without a page name.
CacheNameThe name of the cache.

Ee797730.note(en-US,CS.20).gif Note

  • The ConnecitonString, TableName, and CacheName keys are required. If any of them are not set the LRUCacheFlush object will not register the cache.

The LRUCacheFlush object registers the LRUCache object so that it can be flushed from Commerce Server Business Desk.

The default maximum size of the cache is 1000 items but you can set the size to whatever you need by using the SetSize() method.

The cache is designed so that once the number of items in the cache reaches 110% of the maximum size, the 10% least recently used items are flushed.

The algorithm uses an approximate LRU so there is no guarantee that a particular item will or will not be flushed. The cache is agnostic to memory pressure: it only cares about the number of items.

The cache operates by storing data of type VARIANT so you can cache anything that can be stored in a VARIANT.

Ee797730.note(en-US,CS.20).gif Note

  • It is possible to store pointers in the cache, and then delete the underlying objects, which would cause the data to become corrupt. This should not be an issue if you are storing strings.

For additional information about LRUCache, see “Refreshing Commerce Server Caches” at http://go.microsoft.com/fwlink/?LinkId=15097.

To view a sample configuration of the LRUCache object, see Code to Use Caching with a Catalog.

See Also

[C++] CacheManager Object

[Visual Basic] CacheManager Object

Code to Use Caching with a Catalog

Code to Manipulate an LRUCache Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.