A modern caching library for ASP.NET Core featuring group-based keys, configuration validation, and simplified overloads.
- 🔑 Group-based keys (
"users:123") - ⚡ Optimized performance with
GetOrCreate - ✅ Configuration validation with DataAnnotations
- 📐 Nullable reference types support
- 🎛️ appsettings.json configuration
- 🧪 DI-ready Scoped service
| Requirement | Minimum Version |
|---|---|
| .NET | 9.0+ |
| ASP.NET Core | 9.0+ |
dotnet add package AspNetCoreCacheKit{
"CacheOptions": {
"IsEnabled": true,
"Duration": 60 //Expressed in minutes
}
}// With config
builder.Services.AddAspNetCoreCacheKit(builder.Configuration);
// Only defaults (Without appsettings)
builder.Services.AddAspNetCoreCacheKit();[ApiController]
public class UsersController : ControllerBase
{
private readonly ICacheService _cache;
public UsersController(ICacheService cache)
{
_cache = cache;
}
[HttpGet]
public async Task<IActionResult> GetUsers()
{
// With group
var users = await _cache.GetOrCreateAsync("users", "all", GetUsersFromDb);
// Without group (overload)
var config = _cache.GetOrCreate("app:config", LoadConfig);
return Ok(users);
}
}