A high-performance in-memory and hybrid cache for Go, featuring adaptive W-TinyLFU eviction and hierarchical timer wheels.
Theine is a high-performance in-memory and hybrid cache library for Go, inspired by Caffeine. It provides efficient caching with excellent hit ratios using adaptive W-TinyLFU eviction and automatic expiration management via hierarchical timer wheels, making it suitable for performance-critical applications.
Go developers building high-performance applications that require efficient in-memory caching, such as web servers, microservices, or data-intensive systems where low latency and high throughput are critical.
Developers choose Theine for its combination of high hit ratios from adaptive W-TinyLFU, efficient expiration handling with hierarchical timer wheels, and a clean, idiomatic Go API with generics support, offering a robust alternative to libraries like Ristretto and Otter.
high performance in-memory cache
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses W-TinyLFU eviction that dynamically adapts to access patterns, achieving excellent hit ratios as demonstrated in benchmarks with distributions like zipf and s3.
Implements hierarchical timer wheels to automatically remove expired entries with minimal performance overhead, ensuring timely cleanup.
Supports Go generics for type-safe caching of any key-value types, providing a clean and idiomatic interface that reduces boilerplate.
Allows saving and restoring cache state via Gob encoding, useful for stateful applications that need to maintain cache across restarts, though with versioning caveats.
Secondary cache integration is labeled experimental, with limitations like no persistence support and only REMOVED events for removal listeners, making it unreliable for production.
Cache persistence files are not guaranteed to be compatible across Theine versions, requiring manual management or cache warm-up after upgrades, as noted in the documentation.
Options like UseEntryPool and Doorkeeper introduce tuning complexity and potential race conditions if misconfigured, adding overhead for developers unfamiliar with internal mechanics.
theine is an open-source alternative to the following products: