Open sandboxFocus

Class RedisCacheInvalidator

An implementation of CacheInvalidator that uses Redis publish/subscribe channels to invalidate several instances of local caches.

Inheritance
RedisCacheInvalidator
Implements
Namespace: PostSharp.Patterns.Caching.Backends.Redis
Assembly: PostSharp.Patterns.Caching.Backends.Redis.dll
Syntax
public class RedisCacheInvalidator : CacheInvalidator, IDisposable
Remarks

Use this component when you have a Redis server but want to store cached values in a local in-memory cache, for example when the latency of the Redis server is too high for caching. Create it with Create(CachingBackend, IConnectionMultiplexer, RedisCacheInvalidatorOptions) or CreateAsync(CachingBackend, IConnectionMultiplexer, RedisCacheInvalidatorOptions, CancellationToken), passing the local caching backend, and assign the result to DefaultBackend. All instances of the application must use the same ChannelName.

If you already store cached values in Redis with RedisCachingBackend, you do not need this component. To add a local cache in front of Redis, use IsLocallyCached instead.

Properties

Name Description
Connection

Gets the Redis StackExchange.Redis.IConnectionMultiplexer used by the current RedisCacheInvalidator.

Methods

Name Description
Create(CachingBackend, IConnectionMultiplexer, RedisCacheInvalidatorOptions)

Creates a new RedisCacheInvalidator.

CreateAsync(CachingBackend, IConnectionMultiplexer, RedisCacheInvalidatorOptions, CancellationToken)

Asynchronously creates a new RedisCacheInvalidator.

DisposeAsyncCore(CancellationToken)

Asynchronously disposes the current CachingBackend. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked.

DisposeCore(bool)

Synchronously disposes the current CachingBackend. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked.

SendMessageAsync(string, CancellationToken)

Sends an invalidation message over the message bus of the implementation.

See Also