Unfucked.Caching
v0.0.1-beta.2Pre-release
.NETStandard2.0.NETStandard2.1
Fix Microsoft.Extensions.Caching.Memory.MemoryCache not being typesafe or allowing loader functions. Inspired by Guava Cache.
Published
Nov 6, 2025
11mo ago
Total Downloads
1.3K
1,295
Install
dotnet add package Unfucked.Caching --version 0.0.1-beta.2
| Product | Versions |
|---|---|
| .NET Standard |
README
🧰 Unfucked.Caching
Type-safe in-memory cache with optional automatic loaders. Inspired by Guava Cache.
Installation
dotnet add package Unfucked.Caching
using Unfucked.Caching;
Usage
Setting and getting values
Manual
using Cache<string, int> cache = new InMemoryCache<string, int>();
await cache.Put("a", 1);
int length = await cache.Get("a");
Semi-automatic
using Cache<string, int> cache = new InMemoryCache<string, int>();
int length = await cache.Get("a", async str => str.Length);
Automatic
using Cache<string, int> cache = new InMemoryCache<string, int>(loader: async str => str.Length);
int length = await cache.Get("a");
Expiration
Manual
cache.Invalidate("a");
cache.InvalidateAll();
Expire after last write
using Cache<string, int> cache = new InMemoryCache<string, int>(options: new CacheOptions {
ExpireAfterWrite: TimeSpan.FromHours(1)
});
Expire after last read
using Cache<string, int> cache = new InMemoryCache<string, int>(options: new CacheOptions {
ExpireAfterRead: TimeSpan.FromHours(1)
});
Automatically refresh after last write
using Cache<string, int> cache = new InMemoryCache<string, int>(options: new CacheOptions {
RefreshAfterWrite: TimeSpan.FromHours(1)
});
All Unfucked libraries
Changes from Previous Version
v0.0.1-beta.1v0.0.1-beta.2
Added Frameworks
.NETStandard2.1
Added Dependencies
System.Threading.Tasks.Extensions(.NETStandard2.0)
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.
