The document for 2.0.1 is in continously updating.

Cache

Add add key, cached item and the token for the lifetime
AddIfNotExists add key, cached iem and the token for the lifetime. If the key has already existed, the getvalues action will not invoked.
AddRange add a collection of data to the cache. It is recommended to enclose the AddRange with BeginAddRange and EndAddRange
BeginAddRange Begin to add the range of data. Actually, it will add a lock on the cache items. The cache items are not accessible if they are locked.
EndAddRange End to add the range of data. It will release the lock on the cached items.
Remove remove the cache item with the key
Get get the cache item with the key. If the token is slided, the lifetime of the cache item will be renewed according to the lifetime.
TryGet try to get the cache item with the key.If the token is slided, the lifetime of the cache item will be renewed according to the lifetime.
GetWithCreate try to get teh cache item with the key. If the cache item is not existing, the create action will be invoked to create the cache item.
Reset clear the cache item with the specified reset filter value.
Count return the number of cache items

CacheManager

Init initialize the caches. It will run in a seperate thread
IsIniJobStart a flag indicating all the caches are ready to initialize
WaitWhileInitStart block the main thread to wait the IsIniJobStart set to true
ResetCaches reset the caches in the cachemanager. It has resetFilter as a parameter. If resetFilter is 0, all the caches will be reset.
RemoveAllCaches remove all caches in the cache manager. If the cached item implements IDisposable interface, the Dispose will be invoked.
Dispose dispose all the caches and stop the background work thread
GetCache<TKey,TValue> return the instance of the cache with specified type of key and type of value.
RemoveCache<TKey, TValue> remove the instance of the cache with specified type of key and type of value.
Instance Return the singleton instance of the cacheManager

IToken

IsCurrent

a property for determining if the cache item is still live. If it returns false, it will be removed from the cache.
Renew update the lifetime of the cache item.
ResetFilter a flag value used to reset. If the value meet the value in CacheManager.Instance.ResetCaches, the cached item with the filter will be removed.

ICacheJob

Reset Reset the cache.  It takes the resetFilter as a parameter. The cache items that have the tokens meeting the resetFitler will be removed.
CheckExpireation Check the cache items. If expired cache items are found out, they will be removed.

The default Implementation of IToken

The following tokens will meet your common requirements. However, you can customize the token by implementing IToken.

BaseToken
BaseToken(long) It only takes a reset filter. It will never expire
AbsoluteTimeToken
AbsoluteTimeToken(int,long) The first parameter is the lifetime of the token. The second parameter is the reset filter.
The token will expire after the amount of lifetime passes.
SlideTimeToken
SlideTimeToken(int,long) The first parameter is the lifetime of the token. The second parameter is the reset filter.
The expiration time of the token will move forward if the cache item is accessed in the lifetime of the token.
InstanceToken
InstanceToken(object, long) The first parameter is the instance of object. The second parameter is the reset filter.
The token will expire if the object is collected by GC.

Last edited Sep 14, 2011 at 2:57 PM by czy, version 5

Comments

No comments yet.