Class RedisCacheHandle<TCacheValue>
Cache handle implementation for Redis.
Inherited Members
Namespace:CacheManager.Redis
Assembly:CacheManager.StackExchange.Redis.dll
Syntax
public class RedisCacheHandle<TCacheValue> : BaseCacheHandle<TCacheValue>, ICache<TCacheValue>, IDisposable
Type Parameters
| Name | Description |
|---|---|
| TCacheValue | The type of the cache value. |
Constructors
| Improve this Doc View SourceRedisCacheHandle(ICacheManagerConfiguration, CacheHandleConfiguration, ILoggerFactory, ICacheSerializer)
Initializes a new instance of the RedisCacheHandle<TCacheValue> class.
Declaration
public RedisCacheHandle(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. |
Properties
| Improve this Doc View SourceCount
Gets the number of items the cache handle currently maintains.
Declaration
public override int Count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 | The count. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | No active master found. |
Features
Gets the features the redis server supports.
Declaration
public RedisFeatures Features { get; }
Property Value
| Type | Description |
|---|---|
| StackExchange.Redis.RedisFeatures | The server features. |
IsDistributedCache
Declaration
public override bool IsDistributedCache { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Overrides
IsLuaAllowed
Gets a value indicating whether we can use the lua implementation instead of manual. This flag will be set automatically via feature detection based on the Redis server version or via StrictCompatibilityModeVersion if set to a version which does not support lua scripting.
Declaration
public bool IsLuaAllowed { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Logger
Declaration
protected override ILogger Logger { get; }
Property Value
| Type | Description |
|---|---|
| ILogger |
Overrides
Servers
Gets the servers.
Declaration
public IEnumerable<IServer> Servers { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<StackExchange.Redis.IServer> | The list of servers. |
Methods
| Improve this Doc View SourceAddInternalPrepared(CacheItem<TCacheValue>)
Adds a value to the cache.
Add call is synced, so might be slower than put which is fire and forget but we want to return true|false if the operation was successfully or not. And always returning true could be misleading if the item already exists
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
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
GetCacheItemInternalNoScript(String, String)
Declaration
protected CacheItem<TCacheValue> GetCacheItemInternalNoScript(string key, string region)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key | |
| String | region |
Returns
| Type | Description |
|---|---|
| CacheItem<TCacheValue> |
PutInternal(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 PutInternal(CacheItem<TCacheValue> item)
Parameters
| Type | Name | Description |
|---|---|---|
| CacheItem<TCacheValue> | item | 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
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> |
Overrides
UpdateNoScript(String, String, Func<TCacheValue, TCacheValue>, Int32)
Declaration
protected UpdateItemResult<TCacheValue> UpdateNoScript(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> |