Class MemcachedCacheHandle<TCacheValue>
Cache handle implementation based on the Enyim memcached client.
Inherited Members
Namespace:CacheManager.Memcached
Assembly:CacheManager.Memcached.dll
Syntax
public class MemcachedCacheHandle<TCacheValue> : BaseCacheHandle<TCacheValue>, ICache<TCacheValue>, IDisposable
Type Parameters
Name | Description |
---|---|
TCacheValue | The type of the cache value. |
Constructors
| Improve this Doc View SourceMemcachedCacheHandle(ICacheManagerConfiguration, CacheHandleConfiguration, ILoggerFactory, ICacheSerializer)
Initializes a new instance of the MemcachedCacheHandle<TCacheValue> class.
Declaration
public MemcachedCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory, ICacheSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
ICacheManagerConfiguration | managerConfiguration | The manager configuration. |
CacheHandleConfiguration | configuration | The cache handle configuration. |
ILoggerFactory | loggerFactory | The logger factory. |
ICacheSerializer | serializer | The serializer. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If configuration or loggerFactory is null. |
InvalidOperationException | The cache value type is not serializable or if the enyim configuration section could not be initialized. |
MemcachedCacheHandle(ICacheManagerConfiguration, CacheHandleConfiguration, ILoggerFactory, ICacheSerializer, MemcachedClientConfiguration)
Initializes a new instance of the MemcachedCacheHandle<TCacheValue> class.
Declaration
public MemcachedCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory, ICacheSerializer serializer, MemcachedClientConfiguration clientConfiguration)
Parameters
Type | Name | Description |
---|---|---|
ICacheManagerConfiguration | managerConfiguration | The manager configuration. |
CacheHandleConfiguration | configuration | The cache handle configuration. |
ILoggerFactory | loggerFactory | The logger factory. |
ICacheSerializer | serializer | The serializer. |
Enyim.Caching.Configuration.MemcachedClientConfiguration | clientConfiguration | The Enyim.Caching.Configuration.MemcachedClientConfiguration to use to create the Enyim.Caching.MemcachedClient. |
MemcachedCacheHandle(ICacheManagerConfiguration, CacheHandleConfiguration, ILoggerFactory, ICacheSerializer, MemcachedClient)
Initializes a new instance of the MemcachedCacheHandle<TCacheValue> class.
Declaration
public MemcachedCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory, ICacheSerializer serializer, MemcachedClient client)
Parameters
Type | Name | Description |
---|---|---|
ICacheManagerConfiguration | managerConfiguration | The manager configuration. |
CacheHandleConfiguration | configuration | The cache handle configuration. |
ILoggerFactory | loggerFactory | The logger factory. |
ICacheSerializer | serializer | The serializer. |
Enyim.Caching.MemcachedClient | client | The Enyim.Caching.MemcachedClient to use. |
Properties
| Improve this Doc View SourceCache
Gets the cache.
Declaration
public MemcachedClient Cache { get; }
Property Value
Type | Description |
---|---|
Enyim.Caching.MemcachedClient | The cache. |
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
GetMemcachedClientConfiguration
Gets the get memcached client configuration.
Declaration
public IMemcachedClientConfiguration GetMemcachedClientConfiguration { get; }
Property Value
Type | Description |
---|---|
Enyim.Caching.Configuration.IMemcachedClientConfiguration | The get memcached client configuration. |
IsDistributedCache
Declaration
public override bool IsDistributedCache { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Logger
Declaration
protected override ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Overrides
ServerItemCount
Gets the total number of items per server.
Declaration
public IEnumerable<long> ServerItemCount { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Int64> | The total number of items per server. |
Servers
Gets the servers.
Declaration
public IList<IPEndPoint> Servers { get; }
Property Value
Type | Description |
---|---|
IList<System.Net.IPEndPoint> | The servers. |
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
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
Remarks
Not supported for memcached.
Dispose(Boolean)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
protected override void Dispose(bool disposeManaged)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposeManaged | Indicator if managed resources should be released. |
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
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 |
|
Overrides
Store(StoreMode, CacheItem<TCacheValue>, out Boolean)
Stores the item with the specified mode.
Declaration
protected virtual IStoreOperationResult Store(StoreMode mode, CacheItem<TCacheValue> item, out bool shouldRetry)
Parameters
Type | Name | Description |
---|---|---|
Enyim.Caching.Memcached.StoreMode | mode | The mode. |
CacheItem<TCacheValue> | item | The item. |
Boolean | shouldRetry | Flag indicating if the operation should be retried. Returnd succssess code will be false anyways. |
Returns
Type | Description |
---|---|
Enyim.Caching.Memcached.Results.IStoreOperationResult | The result. |
Remarks
Memcached only supports expiration of seconds, meaning anything less than one second will mean zero, which means it expires right after adding it.
Update(String, Func<TCacheValue, TCacheValue>, Int32)
Declaration
public override UpdateItemResult<TCacheValue> Update(string key, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
Parameters
Type | Name | Description |
---|---|---|
String | key | |
Func<TCacheValue, TCacheValue> | updateValue | |
Int32 | maxRetries |
Returns
Type | Description |
---|---|
UpdateItemResult<TCacheValue> |
Overrides
Update(String, String, Func<TCacheValue, TCacheValue>, Int32)
Declaration
public override UpdateItemResult<TCacheValue> Update(string key, string region, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
Parameters
Type | Name | Description |
---|---|---|
String | key | |
String | region | |
Func<TCacheValue, TCacheValue> | updateValue | |
Int32 | maxRetries |
Returns
Type | Description |
---|---|
UpdateItemResult<TCacheValue> |