Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IBoolCacher ¶ added in v1.0.2
type IBoolCacher interface {
ICloser
GetBool(ctx context.Context, key string) (bool, error)
SetBool(ctx context.Context, key string, value bool, expiration time.Duration) error
}
IBoolCacher 布尔缓存
type ICacher ¶
type ICacher interface {
ISimpleCacher
IIntCacher
IFloatCacher
IObjectCacher
IBoolCacher
// SetNX 设置缓存,如果key存在则返回false
SetNX(ctx context.Context, key string, value string, expiration time.Duration) (bool, error)
}
ICacher 缓存
func NewFreeCache ¶ added in v1.0.2
NewFreeCache 创建一个默认的缓存
func NewNutsDbCacher ¶ added in v1.0.2
NewNutsDbCacher creates a new nutsdb cache client.
func NewRedisCacher ¶ added in v1.0.2
NewRedisCacher creates a new redis cacher
type IFloatCacher ¶ added in v1.0.2
type IFloatCacher interface {
ICloser
GetFloat64(ctx context.Context, key string) (float64, error)
SetFloat64(ctx context.Context, key string, value float64, expiration time.Duration) error
}
IFloatCacher 浮点数缓存
type IIntCacher ¶ added in v1.0.2
type IIntCacher interface {
ICloser
// Inc 增加缓存值
Inc(ctx context.Context, key string, expiration time.Duration) (int64, error)
// Dec 减少缓存值
Dec(ctx context.Context, key string, expiration time.Duration) (int64, error)
// IncMax 增加缓存值,如果超过max则返回max
IncMax(ctx context.Context, key string, max int64, expiration time.Duration) (bool, error)
// DecMin 减少缓存值,如果小于min则返回min
DecMin(ctx context.Context, key string, min int64, expiration time.Duration) (bool, error)
// GetInt64 获取缓存
GetInt64(ctx context.Context, key string) (int64, error)
// SetInt64 设置缓存
SetInt64(ctx context.Context, key string, value int64, expiration time.Duration) error
}
IIntCacher 整数缓存
type IObjectCacher ¶ added in v1.0.2
type IObjectCacher interface {
ICloser
// GetObject 获取缓存
GetObject(ctx context.Context, key string, obj IObjectSchema) error
// SetObject 设置缓存
SetObject(ctx context.Context, key string, obj IObjectSchema, expiration time.Duration) error
}
IObjectCacher 对象缓存
type IObjectSchema ¶ added in v1.0.2
type IObjectSchema interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}
IObjectSchema 缓存对象
type ISimpleCacher ¶ added in v1.0.2
type ISimpleCacher interface {
ICloser
// Delete 删除缓存
Delete(ctx context.Context, key string) error
// Exist 判断缓存是否存在
Exist(ctx context.Context, key string) (bool, error)
// Get 获取缓存
Get(ctx context.Context, key string) (string, error)
// Set 设置缓存
Set(ctx context.Context, key string, value string, expiration time.Duration) error
}
ISimpleCacher 简单缓存
Click to show internal directories.
Click to hide internal directories.