Table of Contents

Class RedisSentinelCache

Namespace
Arc4u.Caching.Redis
Assembly
Arc4u.Caching.Redis.dll

An ICache stored in a Redis deployment monitored by Redis Sentinel, resolved with the kind RedisSentinel. The master name, the sentinel endpoints, the password and the database come from the RedisSentinelCacheOption named after the store.

[Export("RedisSentinel", typeof(ICache))]
public class RedisSentinelCache : BaseDistributeCache<RedisSentinelCache>, ICache, IDisposable
Inheritance
RedisSentinelCache
Implements
Inherited Members

Constructors

RedisSentinelCache(ILogger<RedisSentinelCache>, IServiceProvider, IOptionsMonitor<RedisSentinelCacheOption>)

Initializes a new instance of the RedisSentinelCache class.

public RedisSentinelCache(ILogger<RedisSentinelCache> logger, IServiceProvider container, IOptionsMonitor<RedisSentinelCacheOption> options)

Parameters

logger ILogger<RedisSentinelCache>

The logger.

container IServiceProvider

The service provider used to resolve the serializer.

options IOptionsMonitor<RedisSentinelCacheOption>

The named options of the Redis Sentinel caches.

Methods

Initialize(string)

Creates the underlying Redis cache, connected through the sentinels, from the options named store and resolves the IObjectSerialization (the one registered with SerializerName if any, otherwise the default one). When no serializer can be resolved the cache stays uninitialized and the operations throw CacheNotInitializedException. Calling it again on an initialized cache only logs a warning.

public override void Initialize(string store)

Parameters

store string

The name of the cache, as declared in the configuration.

Exceptions

ArgumentException

store is empty.

InvalidOperationException

No sentinel endpoint or no master name is configured.

ToString()

Returns the name of the cache given to Initialize(string).

public override string ToString()

Returns

string

The name of the cache.

Exceptions

InvalidOperationException

The cache has not been initialized.