Documentation
¶
Index ¶
- type GoCache
- func (g *GoCache) Clear() error
- func (g *GoCache) Close() error
- func (g GoCache) Del(key string) error
- func (g *GoCache) DelMulti(keys []string) error
- func (g *GoCache) Get(key string) interface{}
- func (g *GoCache) GetMulti(keys []string) map[string]interface{}
- func (g *GoCache) Has(key string) bool
- func (g *GoCache) Set(key string, val interface{}, ttl time.Duration) (err error)
- func (g GoCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoCache ¶
type GoCache struct {
// contains filtered or unexported fields
}
Example ¶
c := New() key := "name" // set c.Set(key, "cache value", 2*time.Second) fmt.Println(c.Has(key)) // get val := c.Get(key) fmt.Println(val) time.Sleep(2 * time.Second) // get expired val2 := c.Get(key) fmt.Println(val2) // del c.Del(key) fmt.Println(c.Has(key))
Output: true cache value <nil> false
func NewGoCache ¶
Click to show internal directories.
Click to hide internal directories.