redis

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Redis

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

func GetRedis

func GetRedis(name *string, logger *log.Logger) *Redis

GetRedis 获得Redis连接 GetRedis name 连接配置名称,如果不提供名称则使用默认连接 GetRedis return Redis连接,对象内置连接池操作,完成后无需手动关闭连接

func (*Redis) Decr

func (rd *Redis) Decr(key string) int64

Decr 将 key 中储存的数值减一

func (*Redis) DecrBy

func (rd *Redis) DecrBy(key string, increment int64) int64

DecrBy 将 key 中储存的数值减去加上增量 increment

func (*Redis) Del

func (rd *Redis) Del(keys ...string) int

Del 删除 Del keys 传入一个或多个Key Del return 成功删除的个数

func (*Redis) Do

func (rd *Redis) Do(cmd string, values ...interface{}) string

Do 执行Redis操作,这是底层接口 Do cmd 命令 Do values 参数,根据命令传入不同参数 Do return 返回字符串数据,需要根据数据内容自行解析处理

func (*Redis) Exists

func (rd *Redis) Exists(key string) bool

Exists 判断是否Key存在 * key 指定一个Key Exists return 是否存在

func (*Redis) Expire

func (rd *Redis) Expire(key string, seconds int) bool

Expire 设置Key的过期时间 * seconds 过期时间的秒数 Expire return 是否成功

func (*Redis) ExpireAt

func (rd *Redis) ExpireAt(key string, time int) bool

ExpireAt 设置Key的过期时间(指定具体时间) ExpireAt time 过期时间的时间戳,单位秒 ExpireAt return 是否成功

func (*Redis) Get

func (rd *Redis) Get(key string) interface{}

Get 读取Key的内容 * return any 如果是一个对象则返回反序列化后的对象,否则返回字符串

func (*Redis) GetEX

func (rd *Redis) GetEX(key string, seconds int) interface{}

GetEX 读取Key的内容并更新过期时间

func (*Redis) GetSet

func (rd *Redis) GetSet(key string, value interface{}) interface{}

GetSet 将给定 key 的值设为 value ,并返回 key 的旧值(old value)

func (*Redis) HDecr

func (rd *Redis) HDecr(key, field string) int64

HDecr 为哈希表 key 中的指定字段的整数值减去增量1

func (*Redis) HDecrBy

func (rd *Redis) HDecrBy(key, field string, increment int64) int64

HDecrBy 为哈希表 key 中的指定字段的整数值减去增量 increment

func (*Redis) HDel

func (rd *Redis) HDel(key string, fields ...string) int

HDel 删除一个或多个哈希表字段 HDel return 成功删除的个数

func (*Redis) HExists

func (rd *Redis) HExists(key, field string) bool

HExists 查看哈希表 key 中,指定的字段是否存在

func (*Redis) HGet

func (rd *Redis) HGet(key, field string) interface{}

HGet 获取存储在哈希表中指定字段的值 * field 字段

func (*Redis) HGetAll

func (rd *Redis) HGetAll(key string) map[string]interface{}

HGetAll 获取在哈希表中指定 key 的所有字段和值 HGetAll return 返回所有字段的值,如果值是一个对象则返回反序列化后的对象,否则返回字符串

func (*Redis) HIncr

func (rd *Redis) HIncr(key, field string) int64

HIncr 为哈希表 key 中的指定字段的整数值加上增量1

func (*Redis) HIncrBy

func (rd *Redis) HIncrBy(key, field string, increment int64) int64

HIncrBy 为哈希表 key 中的指定字段的整数值加上增量 increment

func (*Redis) HKeys

func (rd *Redis) HKeys(patten string) []string

HKeys 获取所有哈希表中的字段

func (*Redis) HLen

func (rd *Redis) HLen(key string) int

HLen 获取哈希表中字段的数量 HLen return 字段数量

func (*Redis) HMGet

func (rd *Redis) HMGet(key string, fields ...string) []interface{}

HMGet 获取所有给定字段的值 * fields 字段列表

func (*Redis) HMSet

func (rd *Redis) HMSet(key string, fieldAndValues ...interface{}) bool

HMSet 将哈希表 key 中的字段 field 的值设为 value

func (*Redis) HSet

func (rd *Redis) HSet(key, field string, value interface{}) bool

HSet 将哈希表 key 中的字段 field 的值设为 value

func (*Redis) HSetNX

func (rd *Redis) HSetNX(key, field string, value interface{}) bool

HSetNX 只有在字段 field 不存在时,设置哈希表字段的值

func (*Redis) Incr

func (rd *Redis) Incr(key string) int64

Incr 将 key 中储存的数值增一 Incr * int64 最新的计数

func (*Redis) IncrBy

func (rd *Redis) IncrBy(key string, increment int64) int64

IncrBy 将 key 中储存的数值加上增量 increment

func (*Redis) Keys

func (rd *Redis) Keys(patten string) []string

Keys 查询Key * patten 查询条件,例如:"SESS_*" * return []string 查询到的Key列表

func (*Redis) LLen

func (rd *Redis) LLen(key string) int

LLen 获取列表长度 LLen 列表的长度

func (*Redis) LPop

func (rd *Redis) LPop(key string) interface{}

LPop 移出并获取列表的第一个元素

func (*Redis) LPush

func (rd *Redis) LPush(key string, values ...string) int

LPush 将一个或多个值插入到列表头部 LPush return 成功添加的个数

func (*Redis) LRange

func (rd *Redis) LRange(key string, start, stop int) []interface{}

LRange 获取列表指定范围内的元素 LRange return []any 列表数据,如果值是一个对象则返回反序列化后的对象,否则返回字符串

func (*Redis) MGet

func (rd *Redis) MGet(keys ...string) []interface{}

MGet 获取所有(一个或多个)给定 key 的值 MGet return []any 按照查询key的顺序返回结果,如果结果是一个对象则返回反序列化后的对象,否则返回字符串

func (*Redis) MSet

func (rd *Redis) MSet(keyAndValues ...interface{}) bool

MSet 同时设置一个或多个 key-value 对 MSet keyAndValues 按照key-value的顺序依次传入一个或多个数据

func (*Redis) Publish

func (rd *Redis) Publish(channel, data string) bool

Publish 将信息发送到指定的频道 Publish channel 渠道名称 Publish data 数据,字符串格式

func (*Redis) RPop

func (rd *Redis) RPop(key string) interface{}

RPop 移除并获取列表最后一个元素

func (*Redis) RPush

func (rd *Redis) RPush(key string, values ...string) int

RPush 在列表中添加一个或多个值 RPush return 成功添加的个数

func (*Redis) Set

func (rd *Redis) Set(key string, value interface{}) bool

Set 存储内容到Key * value 对象或字符串 * return bool 是否成功

func (*Redis) SetEX

func (rd *Redis) SetEX(key string, seconds int, value interface{}) bool

SetEX 存储内容到Key并设置过期时间

func (*Redis) SetNX

func (rd *Redis) SetNX(key string, value interface{}) bool

SetNX 存储内容到一个不存在的Key,如果Key已经存在则设置失败

Jump to

Keyboard shortcuts

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