Documentation
¶
Index ¶
- func AddPrefix(key string) string
- func Client() any
- func Close() error
- func DecrFloat(ctx context.Context, key string, value float64) (float64, error)
- func DecrInt(ctx context.Context, key string, value int64) (int64, error)
- func Delete(ctx context.Context, keys ...string) (int64, error)
- func Has(ctx context.Context, key string) (bool, error)
- func IncrFloat(ctx context.Context, key string, value float64) (float64, error)
- func IncrInt(ctx context.Context, key string, value int64) (int64, error)
- func Set(ctx context.Context, key string, value any, expiration ...time.Duration) error
- func SetCache(cache Cache)
- type Cache
- type Result
- type SetValueFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
// Has 检测缓存是否存在
Has(ctx context.Context, key string) (bool, error)
// Get 获取缓存值
Get(ctx context.Context, key string, def ...any) Result
// Set 设置缓存值
Set(ctx context.Context, key string, value any, expiration ...time.Duration) error
// GetSet 获取设置缓存值
GetSet(ctx context.Context, key string, fn SetValueFunc) Result
// Delete 删除缓存
Delete(ctx context.Context, keys ...string) (int64, error)
// IncrInt 整数自增
IncrInt(ctx context.Context, key string, value int64) (int64, error)
// IncrFloat 浮点数自增
IncrFloat(ctx context.Context, key string, value float64) (float64, error)
// DecrInt 整数自减
DecrInt(ctx context.Context, key string, value int64) (int64, error)
// DecrFloat 浮点数自减
DecrFloat(ctx context.Context, key string, value float64) (float64, error)
// AddPrefix 添加Key前缀
AddPrefix(key string) string
// Client 获取客户端
Client() any
// Close 关闭缓存
Close() error
}
type Result ¶
type Result interface {
Err() error
Result() (value.Value, error)
Int() (int, error)
Int8() (int8, error)
Int16() (int16, error)
Int32() (int32, error)
Int64() (int64, error)
Uint() (uint, error)
Uint8() (uint8, error)
Uint16() (uint16, error)
Uint32() (uint32, error)
Uint64() (uint64, error)
Float32() (float32, error)
Float64() (float64, error)
Bool() (bool, error)
String() (string, error)
Duration() (time.Duration, error)
Ints() ([]int, error)
Int8s() ([]int8, error)
Int16s() ([]int16, error)
Int32s() ([]int32, error)
Int64s() ([]int64, error)
Uints() ([]uint, error)
Uint8s() ([]uint8, error)
Uint16s() ([]uint16, error)
Uint32s() ([]uint32, error)
Uint64s() ([]uint64, error)
Float32s() ([]float32, error)
Float64s() ([]float64, error)
Bools() ([]bool, error)
Strings() ([]string, error)
Bytes() ([]byte, error)
Durations() ([]time.Duration, error)
Slice() ([]any, error)
Map() (map[string]any, error)
Scan(pointer any) error
}
type SetValueFunc ¶
Click to show internal directories.
Click to hide internal directories.