Tharga.Cache
0.3.6
dotnet add package Tharga.Cache --version 0.3.6
NuGet\Install-Package Tharga.Cache -Version 0.3.6
<PackageReference Include="Tharga.Cache" Version="0.3.6" />
<PackageVersion Include="Tharga.Cache" Version="0.3.6" />
<PackageReference Include="Tharga.Cache" />
paket add Tharga.Cache --version 0.3.6
#r "nuget: Tharga.Cache, 0.3.6"
#:package Tharga.Cache@0.3.6
#addin nuget:?package=Tharga.Cache&version=0.3.6
#tool nuget:?package=Tharga.Cache&version=0.3.6
Tharga.Cache
A flexible .NET caching library with multiple cache strategies, configurable eviction policies, and stale-while-revalidate support — all with a clean DI-first API.
Features
- Four cache strategies — Eternal, Time-To-Live (TTL), Time-To-Idle (TTI), and Scoped
- Eviction policies — LRU, FIFO, or Random when size or count limits are reached
- Stale-while-revalidate — return cached data instantly while refreshing in the background
- Pluggable persistence — in-memory by default, with optional Redis, MongoDB, and file backends
- Composite keys — build cache keys from multiple parts with
KeyBuilder - Monitoring — inspect cache state, item counts, and fetch queue depth via
ICacheMonitor - Background cleanup — built-in WatchDog service removes stale entries automatically
Get Started
dotnet add package Tharga.Cache
// Register
builder.Services.AddCache();
// Use
public class MyService
{
private readonly ITimeToLiveCache _cache;
public MyService(ITimeToLiveCache cache) => _cache = cache;
public Task<Product> GetProductAsync(int id) =>
_cache.GetAsync<Product>($"product-{id}", () => LoadAsync(id), TimeSpan.FromMinutes(10));
}
Persistence Backends
Extend with optional packages to persist beyond memory:
| Package | Backend |
|---|---|
| Tharga.Cache.Redis | Redis |
| Tharga.Cache.MongoDB | MongoDB |
| Tharga.Cache.File | Local files |
Documentation
Full documentation, configuration options, and samples are available on the GitHub project page.
License
MIT
| 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
- FluentAssertions (>= 8.9.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
-
net8.0
- FluentAssertions (>= 8.9.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
-
net9.0
- FluentAssertions (>= 8.9.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Tharga.Cache:
| Package | Downloads |
|---|---|
|
Quilt4Net.Toolkit
Tools for Health checks via Quilt4Net.Toolkit.Api and Application Insigts. |
|
|
Tharga.Cache.Redis
Redis cache features. |
|
|
Tharga.Cache.MongoDB
MongoDB cache features. |
|
|
Tharga.Cache.Blazor
Component for manageing the Tharga Cache features in blazor. |
|
|
Tharga.Cache.File
File cache features. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.6 | 222 | 3/25/2026 |
| 0.3.5 | 534 | 2/8/2026 |
| 0.3.0 | 151 | 2/3/2026 |
| 0.2.13 | 908 | 12/13/2025 |
| 0.2.11 | 234 | 12/13/2025 |
| 0.2.9 | 425 | 11/30/2025 |
| 0.2.7 | 394 | 11/17/2025 |
| 0.2.5 | 357 | 11/12/2025 |
| 0.2.3 | 334 | 11/12/2025 |
| 0.1.12 | 200 | 11/1/2025 |
| 0.1.10 | 242 | 10/29/2025 |
| 0.1.8 | 221 | 10/29/2025 |
| 0.1.4 | 211 | 10/27/2025 |
| 0.1.2 | 238 | 10/16/2025 |
| 0.0.28 | 200 | 9/6/2025 |
| 0.0.26 | 336 | 8/5/2025 |
| 0.0.24 | 594 | 7/22/2025 |
| 0.0.22 | 222 | 7/15/2025 |
| 0.0.20 | 201 | 6/16/2025 |
| 0.0.18 | 308 | 4/24/2025 |