Removes dependencies added by a RedisCachingBackend when items are expired or evicted from the cache. At least one instance (ideally a single instance) of the RedisCacheDependencyGarbageCollector must be running whenever a RedisCachingBackend instance that supports dependencies is running, otherwise the cache will use storage to store dependencies that are no longer relevant, and these dependencies will not be removed. If no RedisCacheDependencyGarbageCollector is running while at least one dependency-enabled RedisCachingBackend instance is running, you must initiate a full garbage collection by calling the PerformFullCollectionAsync(RedisCachingBackend, CancellationToken) method.
Implements
Namespace: PostSharp.Patterns.Caching.Backends.Redis
Assembly: PostSharp.Patterns.Caching.Backends.Redis.dll
Syntax
public sealed class RedisCacheDependencyGarbageCollector : IDisposableRemarks
The collector must use the same KeyPrefix and Database
as the application, and its configuration must have SupportsEvents set to true.
It can run in a separate process or service.
The collector performs two tasks. It subscribes to the expired and evicted keyevent notifications of Redis and removes
the dependencies of the removed items. The Redis server must therefore publish these notifications (notify-keyspace-events Exe).
The collector also periodically scans the database and removes unreachable data, according to RedisCacheDependencyGarbageCollectorOptions.
The real-time processing stops while the background task queue is overloaded (see BackgroundTasksOverloadedThreshold).
Several instances can run at the same time, but they process the same notifications, so a single instance is preferable. To start a cleanup manually, call CleanUpAsync(CacheCleanupOptions, CancellationToken).
Properties
| Name | Description |
|---|---|
| Connection | Gets the Redis StackExchange.Redis.IConnectionMultiplexer used by the current object. |
| Database | Gets the Redis StackExchange.Redis.IDatabase used by the current object. |
| Options | Gets the options for the RedisCacheDependencyGarbageCollector. |