/SimpleTTL

Simple TTL on golang

Primary LanguageGoMIT LicenseMIT

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