Documentation ¶
Index ¶
- type Cache
- type RedisClient
- func (r *RedisClient) AsyncFlushDB() error
- func (r *RedisClient) Close() error
- func (r *RedisClient) Decr(key string) (int64, error)
- func (r *RedisClient) DecrBy(key string, decr int64) (int64, error)
- func (r *RedisClient) Delete(key ...string) error
- func (r *RedisClient) Exist(key string) (bool, error)
- func (r *RedisClient) FlushDB() error
- func (r *RedisClient) GetBool(key string) (types.NullBool, error)
- func (r *RedisClient) GetFloat64(key string) (types.NullFloat64, error)
- func (r *RedisClient) GetInt(key string) (types.NullInt, error)
- func (r *RedisClient) GetInt64(key string) (types.NullInt64, error)
- func (r *RedisClient) GetJson(key string, dst interface{}) (bool, error)
- func (r *RedisClient) GetStr(key string) (types.NullString, error)
- func (r *RedisClient) GetTime(key string) (types.NullTime, error)
- func (r *RedisClient) HGetAll(key string) (map[string]string, error)
- func (r *RedisClient) HGetAllWIthMap(key string) (map[string]string, error)
- func (r *RedisClient) HGetBool(key string, field string) (types.NullBool, error)
- func (r *RedisClient) HGetFloat64(key string, field string) (types.NullFloat64, error)
- func (r *RedisClient) HGetInt(key string, field string) (types.NullInt, error)
- func (r *RedisClient) HGetInt64(key string, field string) (types.NullInt64, error)
- func (r *RedisClient) HGetJson(key string, field string, dst interface{}) (bool, error)
- func (r *RedisClient) HGetStr(key string, field string) (types.NullString, error)
- func (r *RedisClient) HGetTime(key string, field string) (types.NullTime, error)
- func (r *RedisClient) HKeys(key string) ([]string, error)
- func (r *RedisClient) HLen(key string) (int64, error)
- func (r *RedisClient) HSet(key string, info map[string]interface{}) error
- func (r *RedisClient) HSetJson(key, field string, value interface{}) error
- func (r *RedisClient) Heartbeat() error
- func (r *RedisClient) Incr(key string) (int64, error)
- func (r *RedisClient) IncrBy(key string, incr int64) (int64, error)
- func (r *RedisClient) LAllMemberFloat64(key string) ([]int64, error)
- func (r *RedisClient) LAllMemberInt(key string) ([]int, error)
- func (r *RedisClient) LAllMemberInt64(key string) ([]int64, error)
- func (r *RedisClient) LAllMemberStr(key string) ([]string, error)
- func (r *RedisClient) LFirstMemberFloat64(key string) (types.NullFloat64, error)
- func (r *RedisClient) LFirstMemberInt(key string) (types.NullInt, error)
- func (r *RedisClient) LFirstMemberInt64(key string) (types.NullInt64, error)
- func (r *RedisClient) LFirstMemberStr(key string) (types.NullString, error)
- func (r *RedisClient) LLen(key string) (int64, error)
- func (r *RedisClient) LMembersFloat64(key string, start, end int) ([]float64, error)
- func (r *RedisClient) LMembersInt(key string, start, end int) ([]int, error)
- func (r *RedisClient) LMembersInt64(key string, start, end int) ([]int64, error)
- func (r *RedisClient) LMembersStr(key string, start, end int) ([]string, error)
- func (r *RedisClient) LPop(key string) (types.NullString, error)
- func (r *RedisClient) LPopWithCount(key string, count int) ([]string, error)
- func (r *RedisClient) LPush(key string, value ...interface{}) error
- func (r *RedisClient) LRem(key string, value interface{}) error
- func (r *RedisClient) LRemFirstOne(key string, value interface{}) error
- func (r *RedisClient) LRemLastOne(key string, value interface{}) error
- func (r *RedisClient) LRemWithCount(key string, value interface{}, count int) error
- func (r *RedisClient) LTrim(key string, start, end int) error
- func (r *RedisClient) MSet(data map[string]interface{}) error
- func (r *RedisClient) RPop(key string) (types.NullString, error)
- func (r *RedisClient) RPopLPush(src, dst string) (string, error)
- func (r *RedisClient) RPopWithCount(key string, count int) ([]string, error)
- func (r *RedisClient) RPush(key string, value ...interface{}) error
- func (r *RedisClient) SAdd(key string, value ...interface{}) error
- func (r *RedisClient) SIsMember(key string, value interface{}) (bool, error)
- func (r *RedisClient) SMembers(key string) ([]string, error)
- func (r *RedisClient) SMembersFloat64(key string) ([]float64, error)
- func (r *RedisClient) SMembersInt(key string) ([]int, error)
- func (r *RedisClient) SMembersInt64(key string) ([]int64, error)
- func (r *RedisClient) SMembersTime(key string) ([]time.Time, error)
- func (r *RedisClient) SPopBool(key string) (types.NullBool, error)
- func (r *RedisClient) SPopFloat64(key string) (float64, error)
- func (r *RedisClient) SPopInt(key string) (types.NullInt, error)
- func (r *RedisClient) SPopInt64(key string) (types.NullInt64, error)
- func (r *RedisClient) SPopStr(key string) (types.NullString, error)
- func (r *RedisClient) SRem(key string, dst ...interface{}) (int64, error)
- func (r *RedisClient) Set(key string, value interface{}, exp int) (err error)
- func (r *RedisClient) SetExpire(key string, exp int) error
- func (r *RedisClient) SetJson(key string, value interface{}, exp int) (err error)
- func (r *RedisClient) SetNX(key string, value interface{}, exp int) (bool, error)
- func (r *RedisClient) SetWithNoExpire(key string, value interface{}) (err error)
- func (r *RedisClient) TTL(key string) (types.NullFloat64, error)
- func (r *RedisClient) WatchHeartbeat()
- func (r *RedisClient) ZAdd(key string, members ...*redis.Z) error
- func (r *RedisClient) ZCount(key string, scoreMin, scoreMax string) (int64, error)
- func (r *RedisClient) ZCountWithFloat64(key string, scoreMin, scoreMax float64) (int64, error)
- func (r *RedisClient) ZCountWithInt(key string, scoreMin, scoreMax int) (int64, error)
- func (r *RedisClient) ZCountWithInt32(key string, scoreMin, scoreMax int32) (int64, error)
- func (r *RedisClient) ZCountWithInt64(key string, scoreMin, scoreMax int64) (int64, error)
- func (r *RedisClient) ZRange(key string, start, end int64) ([]string, error)
- func (r *RedisClient) ZRangeByScore(key string, scoreMin, scoreMax string, reverse bool) ([]redis.Z, error)
- func (r *RedisClient) ZRangeWithCount(key string, count int64) ([]string, error)
- func (r *RedisClient) ZRank(key string, member string) (int64, error)
- func (r *RedisClient) ZRem(key string, members ...interface{}) (int64, error)
- func (r *RedisClient) ZRemRangeByRank(key string, start, end int64) (uint64, error)
- func (r *RedisClient) ZRemRangeByRankCount(key string, count int64) (uint64, error)
- func (r *RedisClient) ZRemRangeByScore(key string, min, max string) (uint64, error)
- func (r *RedisClient) ZRevRange(key string, start, end int64) ([]string, error)
- func (r *RedisClient) ZRevRangeWithCount(key string, count int64) ([]string, error)
- func (r *RedisClient) ZRevRank(key string, member string) (int64, error)
- func (r *RedisClient) ZScore(key string, value string) (types.NullFloat64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶ added in v1.3.2
type Cache struct { Network string `yaml:"network" json:"network"` // 网络类型, tcp or unix,默认tcp Addr string `yaml:"addr" json:"addr"` // Redis地址 eg: localhost:6379 User string `yaml:"user" json:"user"` // 用户, redis6.0开始支持 Pwd string `yaml:"pwd" json:"pwd"` // 密码 MinFreeConnCount int `yaml:"minFreeConnCount" json:"minFreeConnCount"` // 最小闲置连接数, 默认是3 MaxOpenConnCount int `yaml:"maxOpenConnCount" json:"maxOpenConnCount"` // 最大连接数, 默认是10 FreeMaxLifetime int `yaml:"freeMaxLifetime" json:"freeMaxLifetime"` // 闲置连接存活的最大时间, -1表示无限制, 默认是10分钟, 单位: 秒 ConnMaxLifetime int `yaml:"connMaxLifetime" json:"connMaxLifetime"` // 连接存活最大时长, 默认是1小时, 单位: 秒 Database int `yaml:"database" json:"database"` // 数据库 ConnectTimeout int `yaml:"connectTimeout" json:"connectTimeout"` // 建立连接超时时间, 默认是5秒, 单位: 秒 ReadTimeout int `yaml:"readTimeout" json:"readTimeout"` // 读取超时时间, -1表示无超时, 默认是3秒, 单位: 秒 WriteTimeout int `yaml:"writeTimeout" json:"writeTimeout"` // 写超时时间, 默认和ReadTimeout保持一致, 单位: 秒 BusyWaitTimeOut int `yaml:"busyWaitTimeOut" json:"busyWaitTimeOut"` // 当所有连接都处在繁忙状态时, 客户端等待可用连接的最大等待时长,默认为3秒 MaxRetries int `yaml:"maxRetries" json:"maxRetries"` // 最大尝试次数, -1表示不重试, 默认是3 }
Cache 缓存配置
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
func NewRedisClient ¶
func NewRedisClient(client *redis.Client, rawConfig *Cache) *RedisClient
func (*RedisClient) DecrBy ¶
func (r *RedisClient) DecrBy(key string, decr int64) (int64, error)
DecrBy 减少指定数量
func (*RedisClient) GetBool ¶
func (r *RedisClient) GetBool(key string) (types.NullBool, error)
GetBool GetBool
func (*RedisClient) GetFloat64 ¶
func (r *RedisClient) GetFloat64(key string) (types.NullFloat64, error)
GetFloat64 GetFloat64
func (*RedisClient) GetInt ¶
func (r *RedisClient) GetInt(key string) (types.NullInt, error)
GetInt GetInt
func (*RedisClient) GetInt64 ¶
func (r *RedisClient) GetInt64(key string) (types.NullInt64, error)
GetInt64 GetInt64
func (*RedisClient) GetJson ¶
func (r *RedisClient) GetJson(key string, dst interface{}) (bool, error)
GetJson GetJson
func (*RedisClient) GetStr ¶
func (r *RedisClient) GetStr(key string) (types.NullString, error)
GetStr GetStr
func (*RedisClient) GetTime ¶
func (r *RedisClient) GetTime(key string) (types.NullTime, error)
GetTime GetTime
func (*RedisClient) HGetAll ¶
func (r *RedisClient) HGetAll(key string) (map[string]string, error)
HGetAll Redis命令hgetall
func (*RedisClient) HGetAllWIthMap ¶
func (r *RedisClient) HGetAllWIthMap(key string) (map[string]string, error)
HGetAllWIthMap Redis命令hgetall, 返回值第一个是key是否存在, 第二个是错误
func (*RedisClient) HGetFloat64 ¶
func (r *RedisClient) HGetFloat64(key string, field string) (types.NullFloat64, error)
HGetFloat64 Redis命令hget
func (*RedisClient) HGetJson ¶
func (r *RedisClient) HGetJson(key string, field string, dst interface{}) (bool, error)
HGetJson Redis命令hget
func (*RedisClient) HGetStr ¶
func (r *RedisClient) HGetStr(key string, field string) (types.NullString, error)
HGetStr Redis命令hget
func (*RedisClient) HKeys ¶
func (r *RedisClient) HKeys(key string) ([]string, error)
HKeys Redis命令hkeys
func (*RedisClient) HSet ¶
func (r *RedisClient) HSet(key string, info map[string]interface{}) error
HSet Redis命令Hset
func (*RedisClient) HSetJson ¶
func (r *RedisClient) HSetJson(key, field string, value interface{}) error
HSetJson Redis命令Hset
func (*RedisClient) Heartbeat ¶ added in v1.1.5
func (r *RedisClient) Heartbeat() error
Heartbeat ping连接
func (*RedisClient) IncrBy ¶
func (r *RedisClient) IncrBy(key string, incr int64) (int64, error)
IncrBy 添加指定数量
func (*RedisClient) LAllMemberFloat64 ¶
func (r *RedisClient) LAllMemberFloat64(key string) ([]int64, error)
LAllMemberFloat64 获取列表全部内容
func (*RedisClient) LAllMemberInt ¶
func (r *RedisClient) LAllMemberInt(key string) ([]int, error)
LAllMemberInt 获取列表全部内容
func (*RedisClient) LAllMemberInt64 ¶
func (r *RedisClient) LAllMemberInt64(key string) ([]int64, error)
LAllMemberInt64 获取列表全部内容
func (*RedisClient) LAllMemberStr ¶
func (r *RedisClient) LAllMemberStr(key string) ([]string, error)
LAllMemberStr 获取列表全部内容
func (*RedisClient) LFirstMemberFloat64 ¶
func (r *RedisClient) LFirstMemberFloat64(key string) (types.NullFloat64, error)
func (*RedisClient) LFirstMemberInt ¶
func (r *RedisClient) LFirstMemberInt(key string) (types.NullInt, error)
func (*RedisClient) LFirstMemberInt64 ¶
func (r *RedisClient) LFirstMemberInt64(key string) (types.NullInt64, error)
func (*RedisClient) LFirstMemberStr ¶
func (r *RedisClient) LFirstMemberStr(key string) (types.NullString, error)
LFirstMemberStr 获取第一个元素, 如果值是nil, 代表列表为空或key不存在
func (*RedisClient) LMembersFloat64 ¶
func (r *RedisClient) LMembersFloat64(key string, start, end int) ([]float64, error)
LMembersFloat64 获取列表全部内容
func (*RedisClient) LMembersInt ¶
func (r *RedisClient) LMembersInt(key string, start, end int) ([]int, error)
LMembersInt 获取列表全部内容
func (*RedisClient) LMembersInt64 ¶
func (r *RedisClient) LMembersInt64(key string, start, end int) ([]int64, error)
LMembersInt64 获取列表全部内容
func (*RedisClient) LMembersStr ¶
func (r *RedisClient) LMembersStr(key string, start, end int) ([]string, error)
LMembersStr 获取列表全部内容
func (*RedisClient) LPop ¶
func (r *RedisClient) LPop(key string) (types.NullString, error)
LPop 从头部删除元素
func (*RedisClient) LPopWithCount ¶
func (r *RedisClient) LPopWithCount(key string, count int) ([]string, error)
LPopWithCount 从头部删除元素
func (*RedisClient) LPush ¶
func (r *RedisClient) LPush(key string, value ...interface{}) error
LPush 往列表插入值
func (*RedisClient) LRem ¶
func (r *RedisClient) LRem(key string, value interface{}) error
LRem 删除列表中所有与value相等的元素
func (*RedisClient) LRemFirstOne ¶
func (r *RedisClient) LRemFirstOne(key string, value interface{}) error
LRemFirstOne 从头部开始删除第一个value相等的元素
func (*RedisClient) LRemLastOne ¶
func (r *RedisClient) LRemLastOne(key string, value interface{}) error
LRemLastOne 从尾部开始删除第一个value相等的元素
func (*RedisClient) LRemWithCount ¶
func (r *RedisClient) LRemWithCount(key string, value interface{}, count int) error
LRemWithCount 删除列表中与value相等的元素, 删除个数为count
func (*RedisClient) LTrim ¶
func (r *RedisClient) LTrim(key string, start, end int) error
LTrim 保留指定start, end 范围的元素, 包括边界元素, 其中start, end为列表下标
func (*RedisClient) RPop ¶
func (r *RedisClient) RPop(key string) (types.NullString, error)
RPop 从尾部删除元素
func (*RedisClient) RPopLPush ¶
func (r *RedisClient) RPopLPush(src, dst string) (string, error)
RPopLPush Redis命令rpoplpush
func (*RedisClient) RPopWithCount ¶
func (r *RedisClient) RPopWithCount(key string, count int) ([]string, error)
RPopWithCount 从头部删除元素
func (*RedisClient) RPush ¶
func (r *RedisClient) RPush(key string, value ...interface{}) error
RPush 往列表插入值
func (*RedisClient) SAdd ¶
func (r *RedisClient) SAdd(key string, value ...interface{}) error
SAdd Redis命令sadd
func (*RedisClient) SIsMember ¶
func (r *RedisClient) SIsMember(key string, value interface{}) (bool, error)
SIsMember Redis命令sismember
func (*RedisClient) SMembers ¶
func (r *RedisClient) SMembers(key string) ([]string, error)
SMembers Redis命令smembers
func (*RedisClient) SMembersFloat64 ¶
func (r *RedisClient) SMembersFloat64(key string) ([]float64, error)
SMembersFloat64 Redis命令smembers
func (*RedisClient) SMembersInt ¶
func (r *RedisClient) SMembersInt(key string) ([]int, error)
SMembersInt Redis命令smembers
func (*RedisClient) SMembersInt64 ¶
func (r *RedisClient) SMembersInt64(key string) ([]int64, error)
SMembersInt64 Redis命令smembers
func (*RedisClient) SMembersTime ¶
func (r *RedisClient) SMembersTime(key string) ([]time.Time, error)
SMembersTime Redis命令smembers
func (*RedisClient) SPopBool ¶
func (r *RedisClient) SPopBool(key string) (types.NullBool, error)
SPopBool Redis命令spop
func (*RedisClient) SPopFloat64 ¶
func (r *RedisClient) SPopFloat64(key string) (float64, error)
SPopFloat64 Redis命令spop
func (*RedisClient) SPopInt ¶
func (r *RedisClient) SPopInt(key string) (types.NullInt, error)
SPopInt Redis命令spop
func (*RedisClient) SPopInt64 ¶
func (r *RedisClient) SPopInt64(key string) (types.NullInt64, error)
SPopInt64 Redis命令spop
func (*RedisClient) SPopStr ¶
func (r *RedisClient) SPopStr(key string) (types.NullString, error)
SPopStr Redis命令spop, 返回删除的值
func (*RedisClient) SRem ¶
func (r *RedisClient) SRem(key string, dst ...interface{}) (int64, error)
SRem Redis命令srem, 返回删除个数
func (*RedisClient) Set ¶
func (r *RedisClient) Set(key string, value interface{}, exp int) (err error)
Set redis命令SET, exp <=0, 则认为无过期时间, exp 单位: 秒
func (*RedisClient) SetExpire ¶
func (r *RedisClient) SetExpire(key string, exp int) error
SetExpire 设置过期时间, exp 单位: s
func (*RedisClient) SetJson ¶
func (r *RedisClient) SetJson(key string, value interface{}, exp int) (err error)
SetJson 设置Json, exp 单位: 秒
func (*RedisClient) SetNX ¶
func (r *RedisClient) SetNX(key string, value interface{}, exp int) (bool, error)
SetNX 存在不操作, 不存在则设置, exp 单位: s
func (*RedisClient) SetWithNoExpire ¶
func (r *RedisClient) SetWithNoExpire(key string, value interface{}) (err error)
SetWithNoExpire redis命令SET, 永久存储
func (*RedisClient) TTL ¶
func (r *RedisClient) TTL(key string) (types.NullFloat64, error)
TTL 获取指定key的过期时间, 返回时间, 单位: s 如果结果是nil, 则key不存在 如果结果值-1, 则key无过期时间 否则值就是key的过期时间
func (*RedisClient) WatchHeartbeat ¶ added in v1.1.4
func (r *RedisClient) WatchHeartbeat()
WatchHeartbeat 监测心跳和重连
func (*RedisClient) ZAdd ¶ added in v1.3.6
func (r *RedisClient) ZAdd(key string, members ...*redis.Z) error
ZAdd Redis命令 zadd
func (*RedisClient) ZCount ¶
func (r *RedisClient) ZCount(key string, scoreMin, scoreMax string) (int64, error)
ZCount Redis命令zcount, 返回score 值在 min 和 max 之间的成员的数量
func (*RedisClient) ZCountWithFloat64 ¶ added in v1.3.8
func (r *RedisClient) ZCountWithFloat64(key string, scoreMin, scoreMax float64) (int64, error)
func (*RedisClient) ZCountWithInt ¶ added in v1.3.8
func (r *RedisClient) ZCountWithInt(key string, scoreMin, scoreMax int) (int64, error)
func (*RedisClient) ZCountWithInt32 ¶ added in v1.3.8
func (r *RedisClient) ZCountWithInt32(key string, scoreMin, scoreMax int32) (int64, error)
func (*RedisClient) ZCountWithInt64 ¶ added in v1.3.8
func (r *RedisClient) ZCountWithInt64(key string, scoreMin, scoreMax int64) (int64, error)
func (*RedisClient) ZRange ¶ added in v1.3.6
func (r *RedisClient) ZRange(key string, start, end int64) ([]string, error)
ZRange Redis命令zrange, 包括start, end 边界值, 返回按照score升序
func (*RedisClient) ZRangeByScore ¶ added in v1.3.6
func (r *RedisClient) ZRangeByScore(key string, scoreMin, scoreMax string, reverse bool) ([]redis.Z, error)
ZRangeByScore Redis命令zrange, 包括start, end 边界值, 返回按照score排序
func (*RedisClient) ZRangeWithCount ¶ added in v1.3.8
func (r *RedisClient) ZRangeWithCount(key string, count int64) ([]string, error)
ZRangeWithCount 返回按照score升序
func (*RedisClient) ZRank ¶ added in v1.3.8
func (r *RedisClient) ZRank(key string, member string) (int64, error)
ZRank Redis命令zrank, 返回按照score升序, 返回排名
func (*RedisClient) ZRem ¶
func (r *RedisClient) ZRem(key string, members ...interface{}) (int64, error)
ZRem Redis命令zrem, 删除指定member的field
func (*RedisClient) ZRemRangeByRank ¶ added in v1.3.6
func (r *RedisClient) ZRemRangeByRank(key string, start, end int64) (uint64, error)
ZRemRangeByRank Redis命令ZREMRANGEBYRANK 根据排名删除 按照score升序
func (*RedisClient) ZRemRangeByRankCount ¶ added in v1.3.8
func (r *RedisClient) ZRemRangeByRankCount(key string, count int64) (uint64, error)
ZRemRangeByRankCount 根据排名升序删除 排名按照score升序
func (*RedisClient) ZRemRangeByScore ¶ added in v1.3.6
func (r *RedisClient) ZRemRangeByScore(key string, min, max string) (uint64, error)
ZRemRangeByScore Redis命令ZREMRANGEBYSCORE
func (*RedisClient) ZRevRange ¶ added in v1.3.8
func (r *RedisClient) ZRevRange(key string, start, end int64) ([]string, error)
ZRevRange Redis命令zrevrange, 包括start, end 边界值, 返回按照score降序
func (*RedisClient) ZRevRangeWithCount ¶ added in v1.3.8
func (r *RedisClient) ZRevRangeWithCount(key string, count int64) ([]string, error)
ZRevRangeWithCount Redis命令zrevrange, 返回按照score降序
func (*RedisClient) ZRevRank ¶ added in v1.3.8
func (r *RedisClient) ZRevRank(key string, member string) (int64, error)
ZRevRank Redis命令zrevrank, 按照score降序, 返回排名
func (*RedisClient) ZScore ¶
func (r *RedisClient) ZScore(key string, value string) (types.NullFloat64, error)
ZScore Redis命令zscore