Class SystemWebCacheHandle<TCacheValue>
Implementation based on Cache.
Inherited Members
Namespace:CacheManager.Web
Assembly:CacheManager.Web.dll
Syntax
public class SystemWebCacheHandle<TCacheValue> : BaseCacheHandle<TCacheValue>, ICache<TCacheValue>, IDisposable
Type Parameters
Name | Description |
---|---|
TCacheValue | The type of the cache value. |
Remarks
Although the MemoryCache doesn't support regions nor a RemoveAll/Clear method, we will implement it via cache dependencies.
Constructors
| Improve this Doc View SourceSystemWebCacheHandle(ICacheManagerConfiguration, CacheHandleConfiguration, ILoggerFactory)
Initializes a new instance of the SystemWebCacheHandle<TCacheValue> class.
Declaration
public SystemWebCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
ICacheManagerConfiguration | managerConfiguration | The manager configuration. |
CacheHandleConfiguration | configuration | The cache handle configuration. |
ILoggerFactory | loggerFactory | The logger factory. |
Properties
| Improve this Doc View SourceContext
Gets the http context being used to get the Cache
instance.
This implementation requires Current to be not null.
Declaration
protected virtual HttpContextBase Context { get; }
Property Value
Type | Description |
---|---|
HttpContextBase | The http context instance. |
Count
Gets the number of items the cache handle currently maintains.
Declaration
public override int Count { get; }
Property Value
Type | Description |
---|---|
Int32 | The count. |
Overrides
Logger
Declaration
protected override ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Overrides
Methods
| Improve this Doc View SourceAddInternalPrepared(CacheItem<TCacheValue>)
Adds a value to the cache.
Declaration
protected override bool AddInternalPrepared(CacheItem<TCacheValue> item)
Parameters
Type | Name | Description |
---|---|---|
CacheItem<TCacheValue> | item | The |
Returns
Type | Description |
---|---|
Boolean |
|
Overrides
Remarks
Be aware that sliding expiration for this cache works only if the timeout is set to more than 2000ms.
Clear()
Clears this cache, removing all items in the base cache and all regions.
Declaration
public override void Clear()
Overrides
ClearRegion(String)
Clears the cache region, removing all items from the specified region only.
Declaration
public override void ClearRegion(string region)
Parameters
Type | Name | Description |
---|---|---|
String | region | The cache region. |
Overrides
Exists(String)
Declaration
public override bool Exists(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key |
Returns
Type | Description |
---|---|
Boolean |
Overrides
Exists(String, String)
Declaration
public override bool Exists(string key, string region)
Parameters
Type | Name | Description |
---|---|---|
String | key | |
String | region |
Returns
Type | Description |
---|---|
Boolean |
Overrides
GetCacheItemInternal(String)
Gets a CacheItem
for the specified key.
Declaration
protected override CacheItem<TCacheValue> GetCacheItemInternal(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key being used to identify the item within the cache. |
Returns
Type | Description |
---|---|
CacheItem<TCacheValue> | The |
Overrides
GetCacheItemInternal(String, String)
Gets a CacheItem
for the specified key.
Declaration
protected override CacheItem<TCacheValue> GetCacheItemInternal(string key, string region)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key being used to identify the item within the cache. |
String | region | The cache region. |
Returns
Type | Description |
---|---|
CacheItem<TCacheValue> | The |
Overrides
PutInternalPrepared(CacheItem<TCacheValue>)
Puts the item into the cache. If the item exists it will get updated with the new value. If the item doesn't exist, the item will be added to the cache.
Declaration
protected override void PutInternalPrepared(CacheItem<TCacheValue> item)
Parameters
Type | Name | Description |
---|---|---|
CacheItem<TCacheValue> | item | The |
Overrides
Remarks
Be aware that sliding expiration for this cache works only if the timeout is set to more than 2000ms.
RemoveInternal(String)
Removes a value from the cache for the specified key.
Declaration
protected override bool RemoveInternal(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key being used to identify the item within the cache. |
Returns
Type | Description |
---|---|
Boolean |
|
Overrides
RemoveInternal(String, String)
Removes a value from the cache for the specified key.
Declaration
protected override bool RemoveInternal(string key, string region)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key being used to identify the item within the cache. |
String | region | The cache region. |
Returns
Type | Description |
---|---|
Boolean |
|