finds.dev← search

// the find

eko/gocache

★ 2,870 · Go · MIT · updated May 2026

☔️ A complete Go cache library that brings you multiple ways of managing your caches

gocache is a Go cache abstraction layer that wraps bigcache, ristretto, go-cache, Redis, memcache, and several others behind a single generic interface. It adds composable layers on top — chain (L1/L2 fallback), loadable (auto-populate on miss), metrics, and marshaling — so you can swap backends without rewriting call sites. It's for Go services that want multi-tier caching without gluing the layers together by hand.

The chain cache's automatic backfill behavior is the best thing here: a miss on ristretto that hits Redis will populate ristretto on the way out, without you writing that logic. Generics support means you get type-safe cache managers instead of casting `interface{}` everywhere. The store interface is narrow enough (7 methods) that writing a custom backend is a legitimate 30-minute task. Tag-based invalidation across any store is genuinely useful and not something most developers want to implement themselves.

The multi-module layout (each store is its own Go module) makes dependency management annoying — you pull in ten `go.mod` files and have to keep version pins in sync manually. Tag invalidation stores tag-to-key mappings in the same backend as the data, so a cache flush wipes your invalidation index too; there's no clean separation. The loadable cache has a thundering herd problem on cold starts — nothing prevents multiple goroutines from simultaneously calling the load function for the same key. Prometheus is the only metrics provider; if you use OpenTelemetry you're writing the adapter yourself.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →