TTLCache is a minimal wrapper over a interface type map in golang, entries of which are
- Thread-safe
- Auto-Expiring after a certain time
- Auto-Extending expiration on
Gets
import (
"time"
"github.com/TukioHQ/ttlcache"
)
func main () {
cache := ttlcache.NewTTLCache(time.Second)
cache.Set("key", 200)
value, exists := cache.Get("key")
count := cache.Count()
}import (
"time"
"github.com/TukioHQ/ttlcache"
)
func main () {
cache := ttlcache.NewCache()
cache.Set("key", 200)
cache.SetTTL("foo", "Bar", time.Second*2)
value, exists := cache.Get("key")
count := cache.Count()
}