-
RedisAdminCache
Class
!!! IMPORTANT !!! This class is only intended to be used as a singleton because we construct the
multiplexer in our constructor, and constructing multiplexers is expensive.We have to use an instance created via DI instead of a static class because we need to be able
inject Configuration to have access to the connection string.-
RedisAdminCache(ILogger<RedisAdminCache>, string)
Constructor
!!! IMPORTANT !!! This class is only intended to be used as a singleton because we construct the
multiplexer in our constructor, and constructing multiplexers is expensive.We have to use an instance created via DI instead of a static class because we need to be able
inject Configuration to have access to the connection string. -
FlushAllAsync()
Method
Delete all the keys of all databases on the server.
-
-
RedisCache
Class
!!! IMPORTANT !!! This class is only intended to be used as a singleton because we construct the
multiplexer in our constructor, and constructing multiplexers is expensive.We have to use an instance created via DI instead of a static class because we need to be able
inject Configuration to have access to the connection string.-
RedisCache(ILogger<RedisCache>, string, bool)
Constructor
.ctor. Initializes the connection multiplexer. -
Multiplexer
Property
The multiplexer used to communicate with redis. -
GetAsync<T>(string)
Method
Get the value of key. If the key does not exist the special value nil is returned. -
GetSubscriber(object)
Method
Obtain a pub/sub subscriber connection to the specified server. -
GetWithSlidingExpiration<T>(string, TimeSpan)
Method
Get the value of key. If the key does not exist the special value nil is returned. If the key does exist,
set or update its expiration time. -
GetWithSlidingExpirationAsync<T>(string, TimeSpan)
Method
Get the value of key. If the key does not exist the special value nil is returned. If the key does exist,
set or update its expiration time. -
IncrementAndExpireOnCreateAsync(string, TimeSpan)
Method
If the key doesn't exist, then create it, increment by one, and set the given expiration.
If the key does exist, just increment the value without modifying the expiration.
NOTE: this is how we implement rate limiting for Attachment downloads in the API, ala https://redis.io/commands/incr#pattern-rate-limiter
-
InitializeConnectionMultiplexer(ConfigurationOptions)
Method
Initialize the connection multiplexer. -
PublishAsync(RedisChannel, RedisValue)
Method
Posts a message to the given channel. -
RemoveAsync(string)
Method
Removes the specified key. A key is ignored if it does not exist. -
RemoveAsync(IReadOnlyCollection<string>)
Method
Removes the specified keys. A key is ignored if it does not exist. Skips the check if there are no keys in
the collection. Throws if any of the keys are null or white space. -
Set(string, object, Nullable<TimeSpan>)
Method
Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous
time to live associated with the key is discarded on successful SET operation. -
SetAsync(string, object, Nullable<TimeSpan>)
Method
Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous
time to live associated with the key is discarded on successful SET operation. -
SubscribeAsync(RedisChannel, Action<RedisChannel,RedisValue>)
Method
Subscribe to perform some operation when a message to the preferred/active node is broadcast, without
any guarantee of ordered handling.
-
-
RedisCacheExtensions
Class
- AddRedisAdminCacheSingleton(this IServiceCollection, string)
Method
Add a RedisAdminCache instance as a singleton. - AddRedisCacheSingleton(this IServiceCollection, string)
Method
Add a RedisCache instance as a singleton.
- AddRedisAdminCacheSingleton(this IServiceCollection, string)
-
RedisCacheLogger
Class
High-performance logging for ASP.NET Core. See: https://learn.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator