- Home
- Caching Software
- Ristretto
Ristretto
What it is
Ristretto is a free, open-source Go library for an in-process cache of key-value data. It is designed for concurrent use, performance, and correctness, and keeps cache entries in memory within a single process. TinyLFU admission and SampledLFU eviction aim to achieve 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; it says goroutines can use the cache concurrently with little throughput degradation. 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 is not distributed. It requires Go 1.21 or above and Go modules. Version 2 supports generics, which the project recommends for new programs. The repository uses the Apache License, Version 2.0, and describes the library as production-ready. Its README names Badger and Dgraph as projects using it.
For and against
For
- Free and licensed under Apache License 2.0.
- Supports concurrent use by goroutines.
- Optional metrics include throughput and hit ratios.
- Version 2 supports generics.
Against
- A new item's Set may be dropped.
- It is not distributed.
- Requires Go 1.21 or above and Go modules.
The verdict
Ristretto offers Go applications an in-memory cache with configurable item costs, admission and eviction policies, and optional metrics. Account for the possibility that a new item may not be admitted and for its single-process scope.
Who it suits
It suits Go developers who need an in-process cache for key-value data and want concurrent access with optional cache metrics. It is intended for a single process, not distributed caching.
Plans and prices
Ristretto
Open-source Go library · in-process cache
Read 8 Oct 2026 · github.com
On the record
- Admission and eviction
- It pairs TinyLFU admission with SampledLFU eviction to target high hit ratios.github.com · read 8 Oct 2026
- Concurrency
- The cache supports concurrent use by goroutines with little throughput degradation, according to the project.github.com · read 8 Oct 2026
- Cost-based eviction
- A valuable large item can evict multiple smaller items, with cost defined by the application.github.com · read 8 Oct 2026
- Deployment scope
- Ristretto is a Go library used in a single process and is not distributed.github.com · read 8 Oct 2026
- Generics
- Version 2 supports generics and is recommended by the project for new programs.github.com · read 8 Oct 2026
- Known users
- The README lists Badger and Dgraph as projects using Ristretto.github.com · read 8 Oct 2026
- License
- The repository is licensed under Apache License, Version 2.0.github.com · read 8 Oct 2026
- Metrics
- Optional metrics cover throughput, hit ratios, and other statistics.github.com · read 8 Oct 2026
- Production status
- The README describes Ristretto as production-ready.github.com · read 8 Oct 2026
- Purpose
- Ristretto is a fast, concurrent, memory-bound Go cache library focused on performance and correctness.github.com · read 8 Oct 2026
- Requirements
- The project says to install Go 1.21 or above and use Go modules.github.com · read 8 Oct 2026
- Set behavior
- A Set for a new item may be dropped while passing through the Set buffer or admission policy, while updates are guaranteed.github.com · read 8 Oct 2026
- Throughput
- The project attributes its throughput to techniques for managing contention, batching, and eventual consistency.github.com · read 8 Oct 2026