Table of Contents

Class RedisCache

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

An ICache stored in a Redis server, resolved with the kind Redis. The connection string and the instance name come from the RedisCacheOption named after the store.

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

Constructors

RedisCache(ILogger<RedisCache>, IServiceProvider, IOptionsMonitor<RedisCacheOption>)

Initializes a new instance of the RedisCache class.

public RedisCache(ILogger<RedisCache> logger, IServiceProvider container, IOptionsMonitor<RedisCacheOption> options)

Parameters

logger ILogger<RedisCache>

The logger.

container IServiceProvider

The service provider used to resolve the serializer.

options IOptionsMonitor<RedisCacheOption>

The named options of the Redis caches.

Methods

Initialize(string)

Creates the underlying Redis cache 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.

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.