An in-memory caching library for .NET — a faithful port of Caffeine.
dotnet add package Espresso.Cachingusing Espresso;
ICache<string, string> cache = Espresso.NewBuilder<string, string>()
.MaximumSize(10_000)
.ExpireAfterWrite(TimeSpan.FromMinutes(5))
.RecordStats()
.Build();
cache.Put("hello", "world");
string? value = cache.GetIfPresent("hello");
// Compute-on-miss: the factory runs at most once per key, atomically.
string computed = cache.Get("key", k => Load(k))!;Espresso is a port of Caffeine by Ben Manes. The eviction policy, timer wheel, and frequency sketch follow its design closely.