-
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()
MethodDelete 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
PropertyThe multiplexer used to communicate with redis. -
GetAsync<T>(string)
MethodGet the value of key. If the key does not exist the special value nil is returned. -
GetSubscriber(object)
MethodObtain a pub/sub subscriber connection to the specified server. -
GetWithSlidingExpiration<T>(string, TimeSpan)
MethodGet 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)
MethodGet 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)
MethodIf 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)
MethodInitialize the connection multiplexer. -
PublishAsync(RedisChannel, RedisValue)
MethodPosts a message to the given channel. -
RemoveAsync(string)
MethodRemoves the specified key. A key is ignored if it does not exist. -
RemoveAsync(IReadOnlyCollection<string>)
MethodRemoves 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>)
MethodSet 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>)
MethodSet 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>)
MethodSubscribe 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)
MethodAdd a RedisAdminCache instance as a singleton. - AddRedisCacheSingleton(this IServiceCollection, string)
MethodAdd a RedisCache instance as a singleton.
- AddRedisAdminCacheSingleton(this IServiceCollection, string)
-
RedisCacheLogger
ClassHigh-performance logging for ASP.NET Core. See: https://learn.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator