Skip to content

ValGoldun/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache

Cache library on pure go

Example without ttl

cache := cache.New[string, string]()

cache.Set("key","value")

value, found := cache.Get("key")
fmt.Println(value, found) //value true

cache.Delete("key")

Example with ttl

cache := cache.New[string, string]()

cache.SetWithTTL("key","value", time.Minute)

value, found := cache.Get("key")
fmt.Println(value, found) //value true

cache.Delete("key")

Example with default ttl

cache := cache.NewWithTTL[string, string](time.Minute)

cache.Set("key","value")

value, found := cache.Get("key")
fmt.Println(value, found) //value true

cache.Delete("key")