I'd like to share a curious cache implementation I recently came up with: https://pkg.go.dev/github.com/Snawoot/secache

It's a small (What's more important is that validity of item is decided by user-provided function. That allows to bring in your own notion of item validity: item age, frequency of the item use, internal state of shared object and so on. E.g. I use it, among other things, to evict per-user instances of "golang.com/x/time/rate".Limiter as soon as token bucket recovered to initial state and limiter has no shared lock being held on it.

Show HN: Secache – Sampling Eviction Cache
pkg.go.dev