C# Class Sage.CacheWrapper

Provides a wrapper around the current System.Web.Caching.Cache, as well as a plain key/value dictionary, so that if System.Web.Caching.Cache is null (as in unit test scenarios), the code using the cache can run without exceptions.
ファイルを表示 Open project: igorfrance/sage

Public Methods

Method Description
CacheWrapper ( ) : System

Initializes a new instance of the CacheWrapper class.

CacheWrapper ( System.Web.HttpContextBase context ) : System

Initializes a new instance of the CacheWrapper class using the specified context.

Get ( string key ) : object

Retrieves the specified item from the cache.

Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies ) : void

Inserts an object into the cache that has file or key dependencies.

Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies, System.DateTime absoluteExpiration, System.TimeSpan slidingExpiration ) : void

Inserts an object into the cache with dependencies and expiration policies.

Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies, System.DateTime absoluteExpiration, System.TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback callback ) : void

Inserts an object into the cache with dependencies, expiration and priority policies, and a delegate you can use to notify your application when the inserted item is removed from the Cache.

Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies, System.DateTime absoluteExpiration, System.TimeSpan slidingExpiration, CacheItemUpdateCallback callback ) : void

Inserts an object into the cache together with dependencies, expiration policies, and a delegate that you can use to notify the application before the item is removed from the cache.

Remove ( string key ) : object

Removes the specified item from the cache.

this ( string key ) : object

Gets or sets the cache item at the specified key.

Private Methods

Method Description
InsertToDictionary ( string key, object value ) : void

Method Details

CacheWrapper() public method

Initializes a new instance of the CacheWrapper class.
public CacheWrapper ( ) : System
return System

CacheWrapper() public method

Initializes a new instance of the CacheWrapper class using the specified context.
public CacheWrapper ( System.Web.HttpContextBase context ) : System
context System.Web.HttpContextBase The current HTTP context.
return System

Get() public method

Retrieves the specified item from the cache.
public Get ( string key ) : object
key string The identifier for the cache item to retrieve.
return object

Insert() public method

Inserts an object into the cache that has file or key dependencies.
public Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies ) : void
key string The cache key that is used to reference the object.
value object The object to insert into the cache.
dependencies System.Web.Caching.CacheDependency The file or cache key dependencies for the item. When any dependency changes, /// the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter /// contains null.
return void

Insert() public method

Inserts an object into the cache with dependencies and expiration policies.
public Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies, System.DateTime absoluteExpiration, System.TimeSpan slidingExpiration ) : void
key string The cache key that is used to reference the object.
value object The object to insert into the cache.
dependencies System.Web.Caching.CacheDependency The file or cache key dependencies for the item. When any dependency changes, /// the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter /// contains null.
absoluteExpiration System.DateTime The time at which the inserted object expires and is removed from the /// cache. To avoid possible issues with local time such as changes from standard time to daylight saving /// time, use instead of for this parameter value. /// If you are using absolute expiration, the slidingExpiration parameter must be set to /// .
slidingExpiration System.TimeSpan The interval between the time that the cached object was last accessed /// and the time at which that object expires. If this value is the equivalent of 20 minutes, the object /// will expire and be removed from the cache 20 minutes after it was last accessed. If you are using /// sliding expiration, the absoluteExpiration parameter must be set to .
return void

Insert() public method

Inserts an object into the cache with dependencies, expiration and priority policies, and a delegate you can use to notify your application when the inserted item is removed from the Cache.
public Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies, System.DateTime absoluteExpiration, System.TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback callback ) : void
key string The cache key that is used to reference the object.
value object The object to insert into the cache.
dependencies System.Web.Caching.CacheDependency The file or cache key dependencies for the item. When any dependency changes, /// the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter /// contains null.
absoluteExpiration System.DateTime The time at which the inserted object expires and is removed from the /// cache. To avoid possible issues with local time such as changes from standard time to daylight saving /// time, use instead of for this parameter value. /// If you are using absolute expiration, the slidingExpiration parameter must be set to /// .
slidingExpiration System.TimeSpan The interval between the time that the cached object was last accessed /// and the time at which that object expires. If this value is the equivalent of 20 minutes, the object /// will expire and be removed from the cache 20 minutes after it was last accessed. If you are using /// sliding expiration, the absoluteExpiration parameter must be set to .
priority CacheItemPriority The cost of the object relative to other items stored in the cache, as expressed /// by the enumeration. This value is used by the cache when it evicts /// objects; objects with a lower cost are removed from the cache before objects with a higher cost.
callback CacheItemRemovedCallback A delegate that will be called before the object is removed from the cache. /// You can use this to update the cached item and ensure that it is not removed from the cache.
return void

Insert() public method

Inserts an object into the cache together with dependencies, expiration policies, and a delegate that you can use to notify the application before the item is removed from the cache.
public Insert ( string key, object value, System.Web.Caching.CacheDependency dependencies, System.DateTime absoluteExpiration, System.TimeSpan slidingExpiration, CacheItemUpdateCallback callback ) : void
key string The cache key that is used to reference the object.
value object The object to insert into the cache.
dependencies System.Web.Caching.CacheDependency The file or cache key dependencies for the item. When any dependency changes, /// the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter /// contains null.
absoluteExpiration System.DateTime The time at which the inserted object expires and is removed from the /// cache. To avoid possible issues with local time such as changes from standard time to daylight saving /// time, use instead of for this parameter value. /// If you are using absolute expiration, the slidingExpiration parameter must be set to /// .
slidingExpiration System.TimeSpan The interval between the time that the cached object was last accessed /// and the time at which that object expires. If this value is the equivalent of 20 minutes, the object /// will expire and be removed from the cache 20 minutes after it was last accessed. If you are using /// sliding expiration, the absoluteExpiration parameter must be set to .
callback CacheItemUpdateCallback A delegate that will be called before the object is removed from the cache. /// You can use this to update the cached item and ensure that it is not removed from the cache.
return void

Remove() public method

Removes the specified item from the cache.
public Remove ( string key ) : object
key string An identifier for the cache item to remove.
return object

this() public method

Gets or sets the cache item at the specified key.
public this ( string key ) : object
key string The key of the item to get.
return object