Skip to content

Commit 01c86ed

Browse files
committed
chore: readme
1 parent d17c5c9 commit 01c86ed

File tree

3 files changed

+11
-45
lines changed

3 files changed

+11
-45
lines changed

README.md

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,7 @@
1-
# L1L2RedisCache
2-
3-
`L1L2RedisCache` is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) with a strong focus on performance. It leverages [`IMemoryCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs) as a level 1 cache and [`RedisCache`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCache.cs) as a level 2 cache, with level 1 evictions being managed via [Redis pub/sub](https://redis.io/topics/pubsub).
4-
5-
`L1L2RedisCache` is heavily inspired by development insights provided over the past several years by [StackOverflow](https://stackoverflow.com/). It attempts to simplify those concepts into a highly accessible `IDistributedCache` implementation that is more performant.
6-
7-
I expect to gracefully decomission this project when [`StackExchange.Redis`](https://github.com/StackExchange/StackExchange.Redis) has [client-side caching](https://redis.io/docs/latest/develop/use/client-side-caching/) support.
8-
9-
## Configuration
10-
11-
It is intended that L1L12RedisCache be used as an `IDistributedCache` implementation.
12-
13-
`L1L2RedisCache` can be registered during startup with the following `IServiceCollection` extension method:
1+
# MessagingRedisCache
142

15-
```
16-
services.AddL1L2RedisCache(options =>
17-
{
18-
options.Configuration = "localhost";
19-
options.InstanceName = "Namespace:Prefix:";
20-
});
21-
```
3+
[`MessagingRedisCache`](/src/MessagingRedisCache/README.md) is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) using [`RedisCache`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCache.cs) as a base implementation. `MessagingRedisCache` will utilize [Redis pub/sub](https://redis.io/topics/pubsub) to ensure that cache entries can be synchronized in a distributed system, where direct deferral to Redis is not always performant. Because of this, it is a functional backing store for [`HybridCache`](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) which will also evict the `IMemoryCache` entries in distributed systems.
224

23-
`L1L2RedisCache` options are an extension of the standard `RedisCache` [`RedisCacheOptions`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCacheOptions.cs). The following additional customizations are supported:
24-
25-
### MessagingType
26-
27-
The type of messaging system to use for L1 memory cache eviction.
28-
29-
| MessagingType | Description | Suggestion |
30-
| - | - | - |
31-
| `Default` | Use standard `L1L2RedisCache` [pub/sub](https://redis.io/topics/pubsub) messages for L1 memory cache eviction. | Default behavior. The Redis server requires no additional configuration. |
32-
| `KeyeventNotifications` | Use [keyevent notifications](https://redis.io/topics/notifications) for L1 memory eviction instead of standard `L1L2RedisCache` [pub/sub](https://redis.io/topics/pubsub) messages. The Redis server must have keyevent notifications enabled. | This is only advisable if the Redis server is already using [keyevent notifications](https://redis.io/topics/notifications) with at least a `ghE` configuration and the majority of keys in the server are managed by `L1L2RedisCache`. |
33-
| `KeyspaceNotifications` | Use [keyspace notifications](https://redis.io/topics/notifications) for L1 memory eviction instead of standard `L1L2RedisCache` [pub/sub](https://redis.io/topics/pubsub) messages. The Redis server must have keyspace notifications enabled. | This is only advisable if the Redis server is already using [keyevent notifications](https://redis.io/topics/notifications) with at least a `ghK` configuration and the majority of keys in the server are managed by `L1L2RedisCache`. |
34-
35-
## Performance
36-
37-
L1L2RedisCache will generally outperform `RedisCache`, especially in cases of high volume or large cache entries. As entries are opportunistically pulled from memory instead of Redis, costs of latency, network, and Redis operations are avoided. Respective performance gains will rely heavily on the impact of afforementioned factors.
38-
39-
## Considerations
5+
# L1L2RedisCache
406

41-
Due to the complex nature of a distributed L1 memory cache, cache entries with sliding expirations are only stored in L2 (Redis). These entries will show no performance improvement over the standard `RedisCache`, but incur no performance penalty.
7+
[`L1L2RedisCache`](/src/L1L2RedisCache/README.MD) is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) with emphasis on performance. It leverages [`IMemoryCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs) as a level 1 cache and [`MessagingRedisCache`](/src/MessagingRedisCache/README.md) as a level 2 cache, with level 1 evictions being managed via [Redis pub/sub](https://redis.io/topics/pubsub).

src/L1L2RedisCache/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# L1L2RedisCache
22

3-
`L1L2RedisCache` is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) with emphasis on performance. It leverages [`IMemoryCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs) as a level 1 cache and [`RedisCache`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCache.cs) as a level 2 cache, with level 1 evictions being managed via [Redis pub/sub](https://redis.io/topics/pubsub) by way of [`MemoryCache`](lol.com).
3+
`L1L2RedisCache` is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) with emphasis on performance. It leverages [`IMemoryCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs) as a level 1 cache and [`MessagingRedisCache`](../MessagingRedisCache/README.md) as a level 2 cache, with level 1 evictions being managed via [Redis pub/sub](https://redis.io/topics/pubsub).
44

55
`L1L2RedisCache` is heavily inspired by development insights provided over the past several years by [StackOverflow](https://stackoverflow.com/). It attempts to simplify those concepts into a highly accessible `IDistributedCache` implementation that is more performant.
66

7-
I expect to gracefully decomission this project when [`StackExchange.Redis`](https://github.com/StackExchange/StackExchange.Redis) has [client-side caching](https://redis.io/docs/latest/develop/use/client-side-caching/) support.
7+
Using a [`HybridCache`](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) combined with [`MessagingRedisCache`](../MessagingRedisCache/README.md) is a viable alternative to this project. It is possible that with the full release of `HybridCache` this project will no longer be necessary.
88

99
## Configuration
1010

src/MessagingRedisCache/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# MessagingRedisCache
22

3-
`MessagingRedisCache` is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) based on [`RedisCache`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCache.cs). It will utilize [Redis pub/sub](https://redis.io/topics/pubsub) to ensure that cache entries can be synchronized in a distributed system, where direct deferral to Redis is not always performant. Because of this, it is a valuable backing store for [HybridCache](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid), and is used as the `IDistributedCache` for [`L1L2RedisCache`](lol.com).
3+
`MessagingRedisCache` is an implementation of [`IDistributedCache`](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IDistributedCache.cs) using [`RedisCache`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCache.cs) as a base implementation. `MessagingRedisCache` will utilize [Redis pub/sub](https://redis.io/topics/pubsub) to ensure that cache entries can be synchronized in a distributed system, where direct deferral to Redis is not always performant. Because of this, it is a functional backing store for [`HybridCache`](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) which will also evict the `IMemoryCache` entries in distributed systems.
44

5-
All changes to entries in `MessagingRedisCache` by way of removal or updates, will result in a message being published. The default implementation is to innately publish these messages. Alternatively, [keyevent notifications](https://redis.io/topics/notifications) or [keyspace notifications](https://redis.io/topics/notifications) can be used if the Redis server is configured for them.
5+
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](https://redis.io/topics/notifications) or [keyspace notifications](https://redis.io/topics/notifications) can be used if the Redis server is configured for them.
66

77
I expect to gracefully decomission this project when [`StackExchange.Redis`](https://github.com/StackExchange/StackExchange.Redis) has [client-side caching](https://redis.io/docs/latest/develop/use/client-side-caching/) support.
88

99
## Configuration
1010

11-
It is intended that `MessagingRedisCache` be used in conjunction with another kind of layered caching solution, specificially [HybridCache](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) or [`L1L2RedisCache`](lol.com). Without any kind of layered cache solution, `MessagingRedisCache` will only publish Redis pub/sub messages for another consumer.
11+
It is intended that `MessagingRedisCache` be used in conjunction with another kind of layered caching solution, specificially [`HybridCache`](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) or [`L1L2RedisCache`](../L1L2RedisCache/README.md). Without any kind of layered cache solution, `MessagingRedisCache` will only publish Redis pub/sub messages for another consumer.
1212

1313
`MessagingRedisCache` can be registered during startup with the following `IServiceCollection` extension method:
1414

@@ -35,11 +35,11 @@ services
3535
.AddMemoryCacheSubscriber();
3636
```
3737

38-
This should be done explicitly when using [HybridCache](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) and is done automatically when using [`L1L2RedisCache`](lol.com).
38+
This should be done explicitly when using [`HybridCache`](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid) and is done automatically when using [`L1L2RedisCache`](../L1L2RedisCache/README.md).
3939

4040
## MessagingRedisCacheOptions
4141

42-
`MessagingRedisCacheOptions` are an extension of the standard `RedisCache` [`RedisCacheOptions`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCacheOptions.cs). The following additional customizations are supported:
42+
`MessagingRedisCacheOptions` are an extension of the standard [`RedisCacheOptions`](https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCacheOptions.cs). The following additional customizations are supported:
4343

4444
### MessagingType
4545

0 commit comments

Comments
 (0)