cache

package
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

func NewRedisClient

func NewRedisClient(client *redis.Client, rawConfig *settings.Cache) *RedisClient

func SetUp added in v1.1.4

func SetUp(conf settings.Cache) (client *RedisClient, err error)

SetUp 初始化缓存

func (*RedisClient) AsyncFlushDB

func (r *RedisClient) AsyncFlushDB() error

AsyncFlushDB 异步清空DB

func (*RedisClient) Close

func (r *RedisClient) Close() error

Close 关闭连接池

func (*RedisClient) Decr

func (r *RedisClient) Decr(key string) (int64, error)

Decr 减1

func (*RedisClient) DecrBy

func (r *RedisClient) DecrBy(key string, decr int64) (int64, error)

DecrBy 减少指定数量

func (*RedisClient) Delete

func (r *RedisClient) Delete(key ...string) error

Delete 删除指定key

func (*RedisClient) Exist

func (r *RedisClient) Exist(key string) (bool, error)

Exist 确认key是否存在

func (*RedisClient) FlushDB

func (r *RedisClient) FlushDB() error

FlushDB 清空DB

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) HGetBool

func (r *RedisClient) HGetBool(key string, field string) (types.NullBool, error)

HGetBool Redis命令hget

func (*RedisClient) HGetFloat64

func (r *RedisClient) HGetFloat64(key string, field string) (types.NullFloat64, error)

HGetFloat64 Redis命令hget

func (*RedisClient) HGetInt

func (r *RedisClient) HGetInt(key string, field string) (types.NullInt, error)

HGetInt Redis命令hget

func (*RedisClient) HGetInt64

func (r *RedisClient) HGetInt64(key string, field string) (types.NullInt64, error)

HGetInt64 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) HGetTime

func (r *RedisClient) HGetTime(key string, field string) (types.NullTime, error)

HGetTime Redis命令hget

func (*RedisClient) HKeys

func (r *RedisClient) HKeys(key string) ([]string, error)

HKeys Redis命令hkeys

func (*RedisClient) HLen

func (r *RedisClient) HLen(key string) (int64, error)

HLen Redis命令hlen

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) Incr

func (r *RedisClient) Incr(key string) (int64, error)

Incr 加1

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) LLen

func (r *RedisClient) LLen(key string) (int64, error)

LLen 列表长度

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) MSet

func (r *RedisClient) MSet(data map[string]interface{}) error

MSet 批量Set

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) ZCount

func (r *RedisClient) ZCount(key string, scoreMin, scoreMax float64) (int64, error)

ZCount Redis命令zcount, 返回score 值在 min 和 max 之间的成员的数量

func (*RedisClient) ZRangeWithScore

func (r *RedisClient) ZRangeWithScore(key string, start, end int, reverse bool) ([]map[string]interface{}, error)

ZRangeWithScore Redis命令zrange, 包括start, end 边界值, 返回按照score排序

func (*RedisClient) ZRem

func (r *RedisClient) ZRem(key string, members ...interface{}) (int64, error)

ZRem Redis命令zrem, 删除指定member的field

func (*RedisClient) ZScore

func (r *RedisClient) ZScore(key string, value string) (types.NullFloat64, error)

ZScore Redis命令zscore

func (*RedisClient) ZSet

func (r *RedisClient) ZSet(key string, score float64, value interface{}) error

ZSet Redis命令zset

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL