Documentation
¶
Overview ¶
Package knife provides cache on `context.Context`.
Index ¶
- func Delete(ctx context.Context, key string)
- func Load(ctx context.Context, key string) (interface{}, error)
- func LoadOrStore(ctx context.Context, key string, val interface{}) (actual interface{}, loaded bool, err error)
- func New(ctx context.Context) (_ context.Context, cached bool)
- func Range(ctx context.Context, f func(key, value interface{}) bool)
- func Store(ctx context.Context, key string, val interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load returns the value stored for a key, or nil if no value is present. If knife is uninitialized, the error of knife uninitialized will be returned.
func LoadOrStore ¶
func LoadOrStore(ctx context.Context, key string, val interface{}) (actual interface{}, loaded bool, err error)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. If knife is uninitialized, the error of knife uninitialized will be returned.
func New ¶
New returns a new context.Context with a *sync.Map bound. If a *sync.Map is already bound, then returns the input context.Context.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.