Documentation ¶
Index ¶
- Variables
- func CreateKey(prefix bool, sep string, visual string, args ...interface{}) string
- func CreateKeyStruct(strct interface{}) string
- func Hash(key string) string
- type Cachex
- func (c *Cachex) Del(ctx context.Context, keys ...string) error
- func (c *Cachex) Get(ctx context.Context, key string, value interface{}, opts ...GetOption) error
- func (c *Cachex) Init(storage cache.Cache, querier Querier, defaultTTL ...int64) *Cachex
- func (c *Cachex) Release()
- func (c *Cachex) Reset() *Cachex
- func (c *Cachex) Set(ctx context.Context, key string, value interface{}, expire int64) error
- func (c *Cachex) UseStaleWhenError(use bool) *Cachex
- type GetOption
- type Options
- type Querier
- type QueryFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTTL int64 = 86400 * 10 * 366
Functions ¶
func CreateKey ¶
CreateKey will generate a key based on the input arguments. When prefix is true, the caller's name will be used to prefix the key in an attempt to make it unique. The args can also be separated using sep. visual performs no functionality. It is used at code level to visually see how the key is structured.
func CreateKeyStruct ¶
func CreateKeyStruct(strct interface{}) string
CreateKeyStruct generates a key by converting a struct into a JSON object.
Types ¶
type Cachex ¶
type Cachex struct {
// contains filtered or unexported fields
}
Cachex 缓存处理类
func NewFromPool ¶ added in v0.7.0
func (*Cachex) UseStaleWhenError ¶
UseStaleWhenError 设置当查询发生错误时,使用过期的缓存数据。该特性需要Storage支持(Get返回过期的缓存数据和Expired错误实现)。默认关闭。
type GetOption ¶
type GetOption func(*Options)
GetOption Get方法的可选参数项结构,不需要直接调用。
func DisableCacheUsage ¶
func UseFreshData ¶
type Options ¶ added in v0.6.0
type Options struct {
// contains filtered or unexported fields
}
Options Get方法的可选参数项
func (*Options) SetDisableCacheUsage ¶ added in v0.6.0
func (*Options) SetQuerier ¶ added in v0.6.0
func (*Options) SetUseFreshData ¶ added in v0.6.0
Click to show internal directories.
Click to hide internal directories.