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
}
func NewCache ¶
NewCache create a new Cache instance, you can set the capacity to 0 if you don't want to limit the cache size
Example ¶
c := NewCache(5*time.Minute, 10000) c.Set("key", "value") v, exist := c.Get("key") if !exist { // not exist } fmt.Println(v) fmt.Printf("Cache hit: %d, cache miss: %d", c.HitNumber(), c.MissNumber())
Output:
Click to show internal directories.
Click to hide internal directories.