TTLCache is a minimal wrapper over a string map in golang, entries of which are
- Thread-safe
- Auto-Expiring after a certain time
- Auto-Extending expiration on
Gets
import (
"time""github.com/wunderlist/ttlcache"
)
funcmain () {
cache:=ttlcache.NewCache(time.Second)
cache.Set("key", "value")
value, exists:=cache.Get("key")
count:=cache.Count()
}