$ show jitbit/FastCache
FastCache is a small, high-performance, thread-safe in-memory cache library for .NET 6+. The core is a generic FastCache<TKey, TValue> class built on ConcurrentDictionary, using Environment.TickCount64 for wrap-free expiration timestamps and a shared, lock-throttled background timer to evict expired entries across all cache instances. It provides atomic GetOrAdd with factory arguments to avoid delegate allocations, indexer-based upserts, and an atomic Remove(key, value) operation. The library is distributed as a NuGet package (Jitbit.FastCache) and includes a BenchmarkDotNet project comparing it to MemoryCache and HybridCache, plus a unit test project covering eviction callbacks and cache semantics.
The LLM identified 2 files worth highlighting for reuse:
Core generic cache implementation. Uses ConcurrentDictionary for thread-safe storage, Environment.TickCount64 for wrap-free expiration timestamps, and a shared lock-throttled timer to evict expired entries across many cache instances. Implements atomic GetOrAdd with factory arguments to avoid delegate allocations, and an atomic Remove(key, value) via ICollection<KeyValuePair<,>>.Remove. This is the reusable heart of the library and demonstrates careful lock-free read-path design.
BenchmarkDotNet harness that measures throughput and allocations for GetOrAdd/TryGetValue across FastCache, MemoryCache, and HybridCache. Useful as a reference for benchmarking cache libraries and validating performance claims.