# dgraph-io/ristretto

A high performance memory-bound Go cache

Repository: https://github.com/dgraph-io/ristretto
Canonical: https://ross.abutalabs.com/products/ristretto
Homepage: https://hypermode.com/blog/introducing-ristretto-high-perf-go-cache
Language: Go
License: Apache-2.0
License Family: permissive
Topics: cache, performance, golang, go, library
Last push: 2026-07-15T16:29:02+00:00

## Health v2 (maintenance only)
Score: 89/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 92, release rhythm 80, longevity 100
- inputs: {"age_days": 2759, "days_push": 49, "days_rel": 57, "gap_med": 60.0, "n_releases_24m": 9}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 6983, forks 444 (observed 2026-08-28T04:09:51.889324+00:00)

## What it is
Ristretto is a high-performance, fully concurrent in-memory cache library for Go, built originally for Dgraph. It uses a TinyLFU admission policy paired with SampledLFU eviction to deliver high hit ratios and throughput, with cost-based eviction and optional metrics.

## Use cases
- add a fast in-memory cache to a Go application
- cache database query results in memory
- reduce contention in a highly concurrent Go service
- cache with cost-based eviction for variable-size items
- improve cache hit ratios over a plain map or LRU
- monitor cache hit ratio and throughput metrics

## When to choose
- you need a production-ready, concurrent memory-bound cache in Go
- hit ratio and throughput under heavy concurrency matter
- you want cost-based eviction for items of varying sizes

## When to avoid
- you need a distributed or shared cache across processes (use Redis or similar)
- your project is not written in Go
- you need persistent or disk-backed caching

## Facets
- artifact type: library
- maturity: stable
- function: caching
- domain: developer-tools, performance, databases
- platform: go, cross-platform
- tags: in-memory-cache, lfu-eviction, tinylfu, concurrent, generics

## Member repositories
- dgraph-io/ristretto (main) score 89

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:09:51.889324+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:41:08.592481+00:00, confidence not recorded.
  - readme: https://github.com/dgraph-io/ristretto (fetched 2026-08-28T04:09:51.889324+00:00, sha 96c52b4ae686)
- Data as of 2026-08-30T08:39:29.467469+00:00.
