Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache - simple implementation of cache More information: https://en.wikipedia.org/wiki/Time_to_live
func NewCache ¶
NewCache - initialization of new cache. For avoid mistake - minimal time to live is 1 minute. For simplification, - key is string and cache haven`t stop method
Example ¶
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) }
Output: Value for key foo is bar
Click to show internal directories.
Click to hide internal directories.