Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Provider ¶
type Provider interface {
Client() interface{}
LRange(ctx context.Context, key string, start, stop int64) []string
LIndex(ctx context.Context, key string, index int64) string
RPush(ctx context.Context, key string, value ...interface{}) bool
LPush(ctx context.Context, key string, value ...interface{}) bool
LLen(ctx context.Context, key string) int64
LPop(ctx context.Context, key string) string
RPop(ctx context.Context, key string) string
SAdd(ctx context.Context, key string, members ...interface{}) bool
SCard(ctx context.Context, key string) int64
SetNX(ctx context.Context, key, value string, expires time.Duration) bool
SMembers(ctx context.Context, key string) []string
// Exists
// @description 判断缓存中是否存在指定的key
// @param key
// @return bool
Exists(ctx context.Context, key string) bool
// String
// @description 根据给定的key从分布式缓存中读取数据并返回,如果不存在或已过期则返回Null。
// @param key 缓存唯一键
// @return string
String(ctx context.Context, key string) string
// Set
// @description 使用指定的key将对象存入分布式缓存中,并使用缓存的默认过期设置,注意,存入的对象必须是可序列化的。
// @param key 缓存唯一键
// @param value 对应的值
// @return bool
Set(ctx context.Context, key, value string) bool
// SetExpires
// @description 使用指定的key将对象存入分部式缓存中,并指定过期时间,注意,存入的对象必须是可序列化的
// @param key 缓存唯一键
// @param value 对应的值
// @param expires 过期时间,单位秒
// @return bool
SetExpires(ctx context.Context, key, value string, expires time.Duration) bool
// Delete
// @description 从缓存中删除指定key的缓存数据。
// @param key
// @return bool
Delete(ctx context.Context, key string) bool
// BatchDelete
// @description 批量删除缓存中的key
// @param keys
BatchDelete(ctx context.Context, keys ...string) bool
// HSet
// @description 将指定key的map数据的某个字段设置为给定的值
// @param key map数据的键
// @param field map的字段名称
// @param value 要设置的字段值
HSet(ctx context.Context, key, field, value string) bool
// HGet
// @description 获取指定key的map数据某个字段的值,如果不存在则返回Null
// @param key map数据的键
// @param field map的字段名称
// @return
HGet(ctx context.Context, key, field string) string
// HGetAll
// @description 获取指定key的map对象,如果不存在则返回Null
// @param key map数据的键
// @return map[string]string
HGetAll(ctx context.Context, key string) map[string]string
// HDelete
// 将指定key的map数据中的某个字段删除。
// @param key map数据的键
// @param field map中的key名称
HDelete(ctx context.Context, key string, fields ...string) bool
// HExists
// 判断缓存中指定key的map是否存在指定的字段,如果key或字段不存在则返回false。
// @param key
// @param field
// @return bool
HExists(ctx context.Context, key, field string) bool
// Val
// 对指定的key结果集执行指定的脚本并返回最终脚本执行的结果。
// @param script 脚本
// @param key 要操作的缓存key
// @param args 脚本的参数列表
// @return
Val(ctx context.Context, script string, keys []string, args ...interface{}) string
// Incr
// 对指定的key执行自增操作
// @param key
// @return bool
Incr(ctx context.Context, key string) bool
// IncrExpires
// 对指定的key执行自增操作,并设置过期时间
// @param key
// @param expires 过期时间,单位秒
// @return bool
IncrExpires(ctx context.Context, key string, expires time.Duration) bool
// IncrByExpires
// 对指定的key执行自增操作,并设置过期时间
// @param key
// @param value
// @param expires 过期时间,单位秒
// @return bool
IncrByExpires(ctx context.Context, key string, value int64, expires time.Duration) bool
// Operate
// 通过直接调用缓存客户端进行缓存操作,该操作适用于高级操作,如果执行失败会返回Null。
// @param operator
// @return err
Operate(ctx context.Context, cmd interface{}) error
// Close
// 关闭客户端
Close()
}
Provider 分布式的缓存操作接口。
func Engine ¶
func Engine(systemId string, cfg configuration.Configuration) (prov Provider)
缓存节点服务器的类型,不同节点类型缓存的数据及其目的有所差异,业务系统要根据实际情况进行选择处理。
Click to show internal directories.
Click to hide internal directories.