Skip to content

Konstantin8105/SimpleTTL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleTTL

Coverage Status Build Status Go Report Card GitHub license GoDoc

Simple TTL on golang for map[string]interface{}, so keys is string and values is something.

See more detail: https://en.wikipedia.org/wiki/Time_to_live

Minimal example of using:

func main(){
	cache := simplettl.NewCache(2 * time.Second)
	key := "foo"
	value := "bar"
	cache.Add(key, value, time.Second)
	if r, ok := cache.Get(key); ok {
		fmt.Printf("Value for key %v is %v",key,r)
	}
}