A high-performance, lightweight, and thread-safe in-memory cache for .NET Core (.NET 6+), offering 7x-10x faster performance than MemoryCache.
FastCache is a high-performance, lightweight, and thread-safe in-memory caching library for .NET Core (.NET 6 and later). It solves the performance and memory overhead issues of the built-in MemoryCache by offering significantly faster read/write operations, generic typing to avoid boxing, and a minimalistic design without unnecessary features like performance counters or automatic memory pressure eviction.
.NET developers building high-performance applications that require efficient in-memory caching, especially those experiencing bottlenecks with the standard MemoryCache.
Developers choose FastCache for its exceptional speed (7x-10x faster than MemoryCache), low memory footprint (8KB DLL), and thread-safe atomic operations, making it ideal for performance-critical scenarios where caching latency and overhead must be minimized.
7x-10x faster alternative to MemoryCache. A high-performance, lighweight (8KB dll) and thread-safe memory cache for .NET.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks in the README show 7x faster reads and 10x faster writes compared to MemoryCache, with minimal memory allocation, making it ideal for latency-sensitive applications.
Designed for safe concurrent access with atomic operations, preventing race conditions in multi-threaded environments, as documented in the atomic behavior section.
Uses strongly typed keys and values to avoid boxing/unboxing overhead and string key allocations, reducing memory usage and improving type safety.
Core DLL is only 8KB with no unnecessary features like performance counters, keeping it lightweight and easy to integrate into projects.
FastCache does not evict items under memory pressure, requiring developers to manually manage cache sizes to prevent memory leaks, as admitted in the tradeoffs section.
Lacks support for distributed caching or persistence, making it unsuitable for scenarios needing shared cache across multiple instances or data durability.
Restricted to .NET Core (.NET 6 and later), so it cannot be used in older .NET Framework or .NET Core versions, limiting backward compatibility.