/ttlcache

an in-memory LRU string-string map with expiration for golang

Primary LanguageGo

TTLCache - an in-memory map-based cache with expiration

TTLCache is a minimal wrapper over a string map in golang, entries of which are

  1. Thread-safe
  2. Auto-Expiring after a certain time
  3. Auto-Extending expiration on Gets

Build Status

Usage

import (
  "time"
  "github.com/gospackler/ttlcache"
)

func main () {
  cache := ttlcache.New(time.Second)
  // ttlcache stores byte slice values.
  cache.Set("key", []byte("value"))
  value, exists := cache.Get("key")
  count := cache.Count()
}