Fork of microsoftarchive/ttlcache
TTLCache is a minimal wrapper over a string map in golang, entries of which are
- Thread-safe
- Auto-Expiring after a certain time
- Optionally auto-Extending expiration on
Get
s
- Auto-extending expiration is now controlled by a Get parameter
- Items may contain any value, not only strings
import (
"time"
"github.com/golightlyb/ttlcache"
)
func main () {
cache := ttlcache.NewCache(time.Second)
cache.Set("key", "any value (interface{})")
updateTTL := false
value, exists := cache.Get("key", updateTTL)
count := cache.Count()
}