CoreSystem.Cache.Redis
2.0.0
dotnet add package CoreSystem.Cache.Redis --version 2.0.0
NuGet\Install-Package CoreSystem.Cache.Redis -Version 2.0.0
<PackageReference Include="CoreSystem.Cache.Redis" Version="2.0.0" />
<PackageVersion Include="CoreSystem.Cache.Redis" Version="2.0.0" />
<PackageReference Include="CoreSystem.Cache.Redis" />
paket add CoreSystem.Cache.Redis --version 2.0.0
#r "nuget: CoreSystem.Cache.Redis, 2.0.0"
#:package CoreSystem.Cache.Redis@2.0.0
#addin nuget:?package=CoreSystem.Cache.Redis&version=2.0.0
#tool nuget:?package=CoreSystem.Cache.Redis&version=2.0.0
⚡ CoreSystem.Cache
Production-ready distributed caching framework for .NET 8
CoreSystem.Cache provides a unified cache abstraction with an execution pipeline, Memory caching, optional external cache storage with fallback, HTTP response caching, OpenTelemetry metrics, and tag-based invalidation.
✨ Features
- ✅ Memory cache provider
- ✅ Cache-Aside (
GetOrAddAsync) - ✅ Tag-based invalidation
- ✅ Optional external cache with Memory fallback
- ✅ HTTP response caching
- ✅ OpenTelemetry metrics for cache hits and misses
- ✅ Configurable execution pipeline
- ✅ Optional resilience integration through
Core.Resilience - ✅ Configurable serialization through
Core.Serialization
Redis support is provided by the CoreSystem.Cache.Redis package, which
registers Redis as the external primary storage and uses Memory as the
fallback storage.
📦 Installation
dotnet add package CoreSystem.Cache
For Redis support, add the Redis provider package separately:
dotnet add package CoreSystem.Cache.Redis
🚀 Quick Start
Register the framework:
builder.Services.AddCoreCache(options =>
{
options.DefaultExpiration = TimeSpan.FromMinutes(30);
});
Inject the cache service:
public sealed class ProductService(ICoreCache cache)
{
}
Store data:
await cache.SetAsync(
"products:1",
product,
TimeSpan.FromMinutes(10));
Retrieve data:
var product = await cache.GetAsync<Product>("products:1");
Recommended Cache-Aside pattern:
var product = await cache.GetOrAddAsync(
$"products:{id}",
async ct => await repository.GetByIdAsync(id, ct),
expiration: TimeSpan.FromMinutes(10),
tags: ["products"]);
🌐 HTTP Response Caching
Enable the middleware:
app.UseCoreCache();
Decorate your endpoint:
[Cacheable(expirationSeconds: 300)]
public async Task<IActionResult> Get(Guid id)
{
return Ok(await service.GetAsync(id));
}
HTTP response caching is applied only to endpoints decorated with
CacheableAttribute. The default request policy allows GET and HEAD
requests and excludes requests containing an Authorization header.
📊 Why CoreSystem.Cache?
| Capability | IDistributedCache |
CoreSystem.Cache |
|---|---|---|
| Memory Provider | ❌ | ✅ |
| Cache-Aside | ❌ | ✅ |
| Tag Invalidation | ❌ | ✅ |
| Primary + Fallback Storage | ❌ | ✅ |
| HTTP Response Caching | ❌ | ✅ |
| OpenTelemetry Metrics | ❌ | ✅ |
| Configurable Cache Pipeline | ❌ | ✅ |
Redis and resilience capabilities are provided through their corresponding CoreSystem packages and are integrated with the cache pipeline when registered and configured.
🏗 Architecture
Application
│
▼
ICoreCache
│
▼
CachePipeline
│
├── Logging
├── Metrics
├── Fallback (when available)
└── Resilience (when registered)
│
▼
Cache Storage Resolver
│
├── External Storage (Primary)
│
└── Memory Storage (Fallback)
When no external cache storage is registered, Memory is used as the primary storage. When one external storage is registered, it becomes the primary storage and Memory becomes the fallback. The core resolver allows only one external cache storage to be registered.
📚 Documentation
The full documentation includes:
- Getting Started
- Architecture
- Configuration
- Basic Usage
- HTTP Response Caching
- Observability
- Health Checks
- Extensibility
- Roadmap
Visit the GitHub repository for the complete documentation.
🤝 Contributing
Issues, discussions and pull requests are welcome.
📄 License
Released under the MIT License.
| 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 was computed. 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 was computed. 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. |
-
net8.0
- CoreSystem.Cache (>= 2.0.0)
- CoreSystem.Cache.Rehydration (>= 2.0.0)
- CoreSystem.Http (>= 1.0.6)
- CoreSystem.Memory (>= 1.0.0)
- CoreSystem.Observability.Abstractions (>= 1.0.0)
- CoreSystem.Redis (>= 1.0.0)
- CoreSystem.Resilience (>= 2.0.0)
- CoreSystem.Serialization (>= 1.2.0)
- MessagePack (>= 3.1.8)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.28)
- Microsoft.Extensions.Options (>= 8.0.2)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Api (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- Polly (>= 8.7.0)
- protobuf-net (>= 3.2.56)
- protobuf-net.Core (>= 3.2.56)
- StackExchange.Redis (>= 2.13.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 77 | 8/16/2026 |