Ristretto
github.com
What it is
Ristretto is a free, open-source Go library for an in-process cache of key-value data, designed for concurrent use, performance and correctness. It keeps data in memory in a single process rather than operating as a distributed cache. TinyLFU admission and SampledLFU eviction are paired to target high hit ratios; applications define item cost, allowing a valuable large item to displace several smaller ones. The project attributes throughput to contention management, batching and eventual consistency. Goroutines can use the cache concurrently with little throughput degradation, according to the project, and optional metrics cover throughput, hit ratios and other statistics. A Set for a new item may be dropped in the Set buffer or admission policy, while updates are guaranteed. Ristretto requires Go 1.21 or later and Go modules. Version 2 supports generics, which the project recommends for new programs. The repository is licensed under Apache License, Version 2.0, and describes the library as production-ready. Its README names Badger and Dgraph as projects using it.
Spec sheet
- Purpose
- Ristretto is a fast, concurrent, memory-bound Go cache library focused on performance and correctness.Read 8 Oct 2026 · github.com
- License
- The repository is licensed under Apache License, Version 2.0.Read 8 Oct 2026 · github.com
- Admission and eviction
- It pairs TinyLFU admission with SampledLFU eviction to target high hit ratios.Read 8 Oct 2026 · github.com
- Concurrency
- The cache supports concurrent use by goroutines with little throughput degradation, according to the project.Read 8 Oct 2026 · github.com
- Cost-based eviction
- A valuable large item can evict multiple smaller items, with cost defined by the application.Read 8 Oct 2026 · github.com
- Deployment scope
- Ristretto is a Go library used in a single process and is not distributed.Read 8 Oct 2026 · github.com
- Generics
- Version 2 supports generics and is recommended by the project for new programs.Read 8 Oct 2026 · github.com
- Known users
- The README lists Badger and Dgraph as projects using Ristretto.Read 8 Oct 2026 · github.com
- Metrics
- Optional metrics cover throughput, hit ratios, and other statistics.Read 8 Oct 2026 · github.com
- Production status
- The README describes Ristretto as production-ready.Read 8 Oct 2026 · github.com
- Requirements
- The project says to install Go 1.21 or above and use Go modules.Read 8 Oct 2026 · github.com
- Set behavior
- A Set for a new item may be dropped while passing through the Set buffer or admission policy, while updates are guaranteed.Read 8 Oct 2026 · github.com
- Throughput
- The project attributes its throughput to techniques for managing contention, batching, and eventual consistency.Read 8 Oct 2026 · github.com
Plans and prices
Strong points and limits
Strong points
- TinyLFU admission and SampledLFU eviction
- Supports concurrent use by goroutines
- Optional throughput and hit-ratio metrics
- Version 2 supports generics
- Updates are guaranteed
Limits
- New-item Set operations may be dropped
- Operates in one process and is not distributed
- Requires Go 1.21 or later
Who it suits
Ristretto suits Go developers needing a concurrent, in-process memory cache and willing to account for admission behavior. It is not a fit for a distributed cache requirement.
Verdict
Ristretto offers an in-process Go cache with configurable item costs and optional metrics. Account for possible dropped new-item writes and its non-distributed scope when evaluating it.
Where Specifiction places it
- Caching Software#13 of 277.5