Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TukioHQ/ttlcache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TTLCache - an in-memory LRU cache with expiration

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

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

Generic TTL Usage

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()
}

Item specific TTL Usage

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()
}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%