MessagingRedisCache 3.0.0-rc.1
dotnet add package MessagingRedisCache --version 3.0.0-rc.1
NuGet\Install-Package MessagingRedisCache -Version 3.0.0-rc.1
<PackageReference Include="MessagingRedisCache" Version="3.0.0-rc.1" />
<PackageVersion Include="MessagingRedisCache" Version="3.0.0-rc.1" />
<PackageReference Include="MessagingRedisCache" />
paket add MessagingRedisCache --version 3.0.0-rc.1
#r "nuget: MessagingRedisCache, 3.0.0-rc.1"
#:package MessagingRedisCache@3.0.0-rc.1
#addin nuget:?package=MessagingRedisCache&version=3.0.0-rc.1&prerelease
#tool nuget:?package=MessagingRedisCache&version=3.0.0-rc.1&prerelease
MessagingRedisCache
MessagingRedisCache is an implementation of IDistributedCache using RedisCache as a base implementation. MessagingRedisCache will utilize Redis pub/sub to ensure that memory cache entries can be synchronized in a distributed system. This makes it a viable backing store for HybridCache, where it can evict IMemoryCache entries in distributed systems.
All changes to entries in MessagingRedisCache by way of removal or updates will result in a Redis message being published. The default implementation is to directly publish these messages in an established channel. Alternatively, keyevent notifications or keyspace notifications can be used if the Redis server is configured for them.
I expect to gracefully decomission this project when StackExchange.Redis has client-side caching support or if HybridCache similarly implements client-side eviction.
Configuration
It is intended that MessagingRedisCache be used in conjunction with another kind of layered caching solution, specificially HybridCache or L1L2RedisCache. Without any kind of layered cache solution, MessagingRedisCache will only publish Redis pub/sub messages for another consumer unconfigured by this project.
MessagingRedisCache can be registered during startup with the following IServiceCollection extension method:
services
.AddMessagingRedisCache(options =>
{
options.Configuration = "redis";
options.InstanceName = "Namespace:Prefix:";
});
Message Subscription
A message subscriber can be registered on the IMessagingRedisCacheBuilder which will automatically evict cache entries from an IMemoryCache registered on the IServiceCollection:
services
.AddMessagingRedisCache(options =>
{
options.Configuration = "redis";
options.InstanceName = "Namespace:Prefix:";
})
.AddMemoryCacheSubscriber();
This is done automatically when using L1L2RedisCache, but should be done explicitly when using HybridCache. A complete HybridCache configuration could appear as such:
var services = new ServiceCollection();
services.AddHybridCache();
services.AddMessagingRedisCache(options =>
{
options.Configuration = "redis";
options.InstanceName = "MessagingRedisCache:Test:";
});
var serviceProvider = services.BuildServiceProvider();
var hybridCache = serviceProvider
.GetRequiredService<HybridCache>();
MessagingRedisCacheOptions
MessagingRedisCacheOptions are an extension of the standard RedisCacheOptions. The following additional customizations are supported:
MessagingType
The type of message publishing system to use:
| MessagingType | Description | Suggestion |
|---|---|---|
Default |
Publish standard MessagingRedisCache pub/sub messages. |
Default behavior. The Redis server requires no additional configuration. |
KeyeventNotifications |
Rely on keyevent notifications for message publishing instead of standard MessagingRedisCache pub/sub messages. The Redis server must have keyevent notifications enabled. |
This is only advisable if the Redis server is already using keyevent notifications with at least a ghE configuration and the majority of keys in the server are managed by MessagingRedisCache. |
KeyspaceNotifications |
Rely on keyspace notifications for message publishing instead of standard MessagingRedisCache pub/sub messages. The Redis server must have keyspace notifications enabled. |
This is only advisable if the Redis server is already using keyevent notifications with at least a ghK configuration and the majority of keys in the server are managed by MessagingRedisCache. |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.1)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.1)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MessagingRedisCache:
| Package | Downloads |
|---|---|
|
L1L2RedisCache
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-rc.1 | 31 | 12/18/2025 |
| 0.0.1-beta.1 | 208 | 12/18/2025 |