Cache
Mango Cache 🥭 - Partial implementation of Guava Cache in Go (golang).
Install / Use
/learn @goburrow/CacheREADME
Mango Cache
Partial implementations of Guava Cache in Go.
Supported cache replacement policies:
- LRU
- Segmented LRU (default)
- TinyLFU (experimental)
The TinyLFU implementation is inspired by Caffeine by Ben Manes and go-tinylfu by Damian Gryski.
Download
go get -u github.com/goburrow/cache
Example
package main
import (
"fmt"
"math/rand"
"time"
"github.com/goburrow/cache"
)
func main() {
load := func(k cache.Key) (cache.Value, error) {
time.Sleep(100 * time.Millisecond) // Slow task
return fmt.Sprintf("%d", k), nil
}
// Create a loading cache
c := cache.NewLoadingCache(load,
cache.WithMaximumSize(100), // Limit number of entries in the cache.
cache.WithExpireAfterAccess(1*time.Minute), // Expire entries after 1 minute since last accessed.
cache.WithRefreshAfterWrite(2*time.Minute), // Expire entries after 2 minutes since last created.
)
getTicker := time.Tick(100 * time.Millisecond)
reportTicker := time.Tick(5 * time.Second)
for {
select {
case <-getTicker:
_, _ = c.Get(rand.Intn(200))
case <-reportTicker:
st := cache.Stats{}
c.Stats(&st)
fmt.Printf("%+v\n", st)
}
}
}
Performance

Related Skills
node-connect
338.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
338.0kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
83.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
