Open sandboxFocus

Class RedisCachingBackendConfiguration

Configuration for Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend.

Inheritance
RedisCachingBackendConfiguration
Namespace: Metalama.Patterns.Caching.Backends.Redis
Assembly: Metalama.Patterns.Caching.Backends.Redis.dll
Syntax
public record RedisCachingBackendConfiguration : CachingBackendConfiguration, IEquatable<CachingBackendConfiguration>, IEquatable<RedisCachingBackendConfiguration>
Remarks

By default, the StackExchange.Redis.IConnectionMultiplexer is retrieved from the IServiceProvider. To define another way to get the StackExchange.Redis.IConnectionMultiplexer, set the Connection or NewConnectionOptions properties.

Constructors

Name Description
RedisCachingBackendConfiguration()

Initializes a new instance of the RedisCachingBackendConfiguration class.

RedisCachingBackendConfiguration(RedisCachingBackendConfiguration)
RedisCachingBackendConfiguration(ConfigurationOptions, string?)

Initializes a new instance of the RedisCachingBackendConfiguration class that creates a new StackExchange.Redis.IConnectionMultiplexer.

RedisCachingBackendConfiguration(IConnectionMultiplexer, ConfigurationOptions?, string?)

Initializes a new instance of the RedisCachingBackendConfiguration class that with a given StackExchange.Redis.IConnectionMultiplexer.

Properties

Name Description
BackgroundRecoveryRetryPolicy

Gets or sets the IRetryPolicy that handles the retry loop of background recovery actions (see InvalidateDependencyInBackground or RemoveItemInBackground). The default value is the default instance of the BackgroundRetryPolicy class.

BackgroundTasksMaxConcurrency

Gets or sets the maximal number of concurrent background tasks. This number must be kept low to avoid overloading the system or the cache with bursts, for instance when Redis processes evictions. The default value is 25.

BackgroundTasksOverloadedThreshold

Gets or sets the number of tasks over which the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend notifies its state as overloaded through the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend.IsBackgroundTaskQueueOverloaded property and the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend.IsBackgroundTaskQueueOverloadedChanged event. The default value is 125. The RedisCacheDependencyGarbageCollector component stops processing real-time eviction and expiration notifications when the component is overloaded.

BackgroundTasksRetryPolicy

Gets or sets the IRetryPolicy that handles the retries of background (non-blocking) operations. The default value is the default instance of the BackgroundRetryPolicy class.

Connection

Gets or sets the StackExchange.Redis.IConnectionMultiplexer that will be used by the Redis CachingBackend.

ConnectionTimeout

Gets the time that the Redis backend will wait for a Redis connection. (When you create a new Redis backend, if it doesn't connect to a Redis server in this timeout, a TimeoutException is thrown.)

CreateSerializer

Gets or sets a function that creates the serializer used to serialize objects into byte arrays (and conversely). The default value is null, which means that JsonCachingSerializer will be used.

Database

Gets or sets the index of the database to use. The default value is -1 (automatic selection).

DefaultExpiration

Gets or sets the default expiration time of cached items. All items that don't have an explicit expiration time are automatically expired according to the value of this property, unless they have the NotRemovable priority. The default value is 1 day.

DisposeTimeout

Gets or sets the timeout of the Dispose methods if no cancellation token is provided. The default is 30 seconds. Note that there are still some situations where the Dispose operation cannot be cancelled or timed out.

EqualityContract
ExceptionHandlingPolicy

Gets or sets the IExceptionHandlingPolicy, which determines how exceptions in the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend component are handled. The default value is an instance of the DefaultExceptionHandlingPolicy class.

InvalidationMaxConcurrency

Gets or sets the maximum number of items that can be invalidated concurrently by a single call of the InvalidateDependency(string), RemoveItem(string), or SetItem(string, CacheItem) method (or their async equivalent). The aim of this setting is to prevent the invalidation of large graphs from overloading the system. Instead, only the expensive invalidation operations will be throttled.

KeyCompressingThreshold

Gets or sets the length threshold over which cache keys are hashed. The default value is 128.

KeyPrefix

Gets or sets the prefix for the key of all Redis items created by the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend. The default value is cache.

LogRedisConnection

Gets or sets a value indicating whether the logs of the StackExchange.Redis.ConnectionMultiplexer should be captured and redirected. The default value is false.

NewConnectionOptions

Gets or sets the StackExchange.Redis.ConfigurationOptions that will be used to create a new StackExchange.Redis.ConnectionMultiplexer for use by the new Redis CachingBackend.

OwnsConnection

Gets or sets a value indicating whether determines whether the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend should dispose the Redis connection when the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend itself is disposed. The default value is false.

ReadCommandFlags

Gets or sets the Redis StackExchange.Redis.CommandFlags for read-only operations. The default value is StackExchange.Redis.CommandFlags.PreferReplica.

RunGarbageCollector

Gets or sets a value indicating whether the dependency garbage collector process should run while the caching back-end instance is alive. This property only makes sense when SupportsDependencies is set to true. The value of RunGarbageCollector is false by default. It is necessary to have at least one instance of the garbage collector active at any time. It is allowed but useless to have several concurrent instances of the garbage collector, but having a large number of them can hurt performance of the Redis server. The recommended approach to run the garbage collector is to deploy a separate application that only hosts this service. See CreateRedisCacheDependencyGarbageCollector(RedisCachingBackendConfiguration, IServiceProvider?) for details.

SupportsDependencies

Gets or sets a value indicating whether the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend should support dependencies. When this property is used, the Metalama.Patterns.Caching.Backends.Redis.DependenciesRedisCachingBackend class is used instead of Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend. Note that when dependencies are enabled, at least one instance of the Redis garbage collection must run. See RunGarbageCollector for details.

SupportsEvents

Determines if the Metalama.Patterns.Caching.Backends.Redis.RedisCachingBackend supports raising events. It is disabled by default.

TransactionMaxRetries

Gets or sets the number of times Redis transactions are retried when they fail due to a data conflict, before an exception is raised. The default value is 5.

TransactionRetryPolicy

Gets or sets the IRetryPolicy that handles the retry loop of Redis transactions. The default value is the default instance of the TransactionRetryPolicy class.

VerifyGraphBeforeDisposing

Gets or sets a value indicating whether to verify the dependency graph consistency before disposing. When enabled, CleanUpAsync(CacheCleanupOptions, CancellationToken) is called during disposal to detect any graph defects, which are reported through the OnGraphDefect(GraphDefectArgs) callback. The default value is false. This is primarily intended for testing.

WriteCommandFlags

Gets or sets the Redis StackExchange.Redis.CommandFlags for write operations. The default value is StackExchange.Redis.CommandFlags.PreferMaster.

Methods

Name Description
Equals(CachingBackendConfiguration?)
Equals(RedisCachingBackendConfiguration?)
Equals(object?)
GetHashCode()
PrintMembers(StringBuilder)
ToString()

Operators

Name Description
operator ==(RedisCachingBackendConfiguration?, RedisCachingBackendConfiguration?)
operator !=(RedisCachingBackendConfiguration?, RedisCachingBackendConfiguration?)

Extension Methods