TTLCache - an in-memory LRU cache with expiration
TTLCache is a minimal wrapper over a map[string][]byte in golang, entries of which are
- Thread-safe
- Auto-Expiring after a certain time
Usage
import (
"time"
"github.com/MalteJ/ttlcache"
)
func main () {
cache := ttlcache.NewCache(time.Second)
cache.Set("key", []byte("value"))
value, exists := cache.Get("key")
count := cache.Count()
}