Slide 13
Slide 13 text
Show the code
func main() {
// create a cache instance
cache, err := ristretto.NewCache(&ristretto.Config{
NumCounters: 10 << 20, // 10M
MaxCost: 1 << 30, // 1GB
BufferItems: 64,
})
if err != nil { log.Fatal(err) }
cache.Set("key", "value", 5) // set a value
time.Sleep(time.MilliSecond) // wait a bit
value, found := cache.Get("key")
if !found { panic("missing value") }
fmt.Println(value)
cache.Del("key")
}