A high-performance, concurrent caching library for Rust inspired by Java's Caffeine.
Moka is a high-performance, concurrent caching library for Rust, built to provide fast in-memory caching with advanced eviction and expiration policies. It solves the problem of efficiently managing cached data in multi-threaded and asynchronous applications, reducing load on backend systems like databases. Inspired by Java's Caffeine library, it offers both synchronous and asynchronous cache implementations.
Rust developers building high-performance applications that require efficient, thread-safe caching, such as web services, APIs, or embedded systems. It's particularly useful for those needing fine-grained control over cache eviction and expiration.
Developers choose Moka for its combination of high concurrency, near-optimal hit ratio using TinyLFU/LRU algorithms, and support for both sync and async environments. Its production use in services like crates.io demonstrates reliability and performance under heavy traffic.
A high performance concurrent caching library for Rust
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 TinyLFU for admission and LRU for eviction, inspired by Caffeine, which maintains near-optimal hit ratios—evidenced by ~85% hit rates in production use at crates.io.
Provides both synchronous and asynchronous cache implementations, with async caches compatible with Tokio and async-std, making it versatile for different runtime environments as shown in the examples.
Supports time-to-live, time-to-idle, and per-entry variable expiration, allowing fine-grained control over cache entry lifetimes, detailed in the expiration policies section.
Used in high-traffic services like crates.io and embedded devices like home routers, demonstrating robustness and performance under real-world load conditions.
Version 0.12.0 had major breaking changes requiring a migration guide, indicating that the API is still evolving and may disrupt existing projects during upgrades.
Does not support WebAssembly, WASI, or no_std environments, restricting its use in browser-based or certain embedded contexts without the standard library.
Admits in the comparison table that it has higher overhead compared to simpler caches like Quick Cache, making it less ideal for performance-critical applications with tight resource constraints.