Documentation ¶
Overview ¶
Example (AdvancedUsage) ¶
codec := newTieredCache() key := "advancedUsage" obj := new(Object) err := codec.SetStatic(key, time.Hour, &Object{ Str: "mystring", Num: 42, }) if err != nil { panic(err) } fmt.Println(obj)
Output: &{mystring 42}
Example (BasicUsage) ¶
codec := newTieredCache() key := "basicUsage" obj := &Object{ Str: "mystring", Num: 42, } _ = codec.SetStatic(key, time.Hour, obj) var wanted Object if err := codec.Get(key, &wanted); err == nil { fmt.Println(wanted) }
Output: {mystring 42}
Index ¶
- Variables
- type Redis
- type Stats
- type TwoTier
- func (tt *TwoTier) Delete(key string) error
- func (tt *TwoTier) Exists(key string) bool
- func (tt *TwoTier) Get(key string, target interface{}) error
- func (tt *TwoTier) Set(key string, expiresIn time.Duration, cb func() (interface{}, error)) (interface{}, error)
- func (tt *TwoTier) SetStatic(key string, expiresIn time.Duration, value interface{}) error
- func (tt *TwoTier) Stats() Stats
- func (tt *TwoTier) UseLocalCache(name string, defaultExpiry time.Duration)
- func (tt *TwoTier) UseRedisCache(redis Redis)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache: key is missing")
View Source
var ErrNilValueProvided = errors.New("cache: nil value(s) can NOT be stored")
Functions ¶
This section is empty.
Types ¶
type TwoTier ¶
type TwoTier struct { R Redis L *inmemory.Cache2Go Marshal func(interface{}) ([]byte, error) Unmarshal func([]byte, interface{}) error // contains filtered or unexported fields }
func (*TwoTier) UseLocalCache ¶ added in v8.0.2
func (*TwoTier) UseRedisCache ¶ added in v8.0.2
Directories ¶
Path | Synopsis |
---|---|
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
|
Package singleflight provides a duplicate function call suppression mechanism. |
Click to show internal directories.
Click to hide internal directories.