redis

package
v3.8.24 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ClientNormal for standard instance client
	ClientNormal = "normal"
	// ClientCluster for official redis cluster
	ClientCluster = "cluster"
	// FailoverClient for official redis failover
	ClientFailover = "failover"
	// RingClient for official redis ring
	ClientRing = "ring"
)

ClientNormal ...

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ClientType string // 模式(normal => 单节点,cluster =>  集群,failover => 哨兵,ring => 分片)
	// Host address with port number
	// For normal client will only used the first value
	// A seed list of host:port addresses of sentinel nodes.
	Hosts []string // 集群 哨兵 需要填写
	// host:port address.
	Addr string // 单节点客户端
	// Map of name => host:port addresses of ring shards.
	Addrs map[string]string // 分片客户端  shardName => host:port
	// The master name.
	MasterName string
	// The network type, either tcp or unix.
	// Default is tcp.
	// Only for normal client
	Network string
	// Database to be selected after connecting to the server.
	Database int // 数据库
	// In normal client this is the MaxRetries option
	MaxRedirects int
	// Enables read queries for a connection to a Redis Cluster slave node.
	IsReadOnly bool
	// Enables routing read-only queries to the closest master or slave node.
	// If set will change this client to read-only mode
	RouteByLatency bool
	// Following options are copied from Options struct.
	Password string // 密码
	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout time.Duration
	// Timeout for socket reads. If reached, commands will fail
	// with a timeout instead of blocking.
	// Default is 3 seconds.
	ReadTimeout time.Duration
	// Timeout for socket writes. If reached, commands will fail
	// with a timeout instead of blocking.
	// Default is 3 seconds.
	WriteTimeout time.Duration
	// PoolSize applies per cluster node and not for the whole cluster.
	// Maximum number of socket connections.
	// Default is 10 connections.
	PoolSize int // 连接池大小
	// Amount of time client waits for connection if all connections
	// are busy before returning an error.
	// Default is ReadTimeout + 1 second.
	PoolTimeout time.Duration
	// Amount of time after which client closes idle connections.
	// Should be less than server's timeout.
	// Default is to not close idle connections.
	IdleTimeout time.Duration
	// Frequency of idle checks.
	// Default is 1 minute.
	// When minus value is set, then idle check is disabled.
	IdleCheckFrequency time.Duration
	// TLS Config to use. When set TLS will be negotiated.
	// Only for normal client
	TLSConfig    *tls.Config
	EnableMetric bool // 开启指标采集
	EnableTrace  bool // 开启链路追踪
	// contains filtered or unexported fields
}

Options options to initiate your client

func NewRedisClient added in v3.4.2

func NewRedisClient(opts ...Option) (*Client, error)

NewRedisClient 创建新的Redis客户端 opts: 配置选项

func (*Client) ACLDryRun added in v3.5.4

func (r *Client) ACLDryRun(ctx context.Context, username string, command ...any) (val string, err error)

ACLDryRun 用于在不实际执行命令的情况下检查用户是否具有执行给定命令的权限。ctx:上下文 username:用户名 command:要检查的命令

func (*Client) ACLLog added in v3.6.4

func (r *Client) ACLLog(ctx context.Context, count int64) (val []*redis.ACLLogEntry, err error)

ACLLog 获取 ACL 日志。ctx:上下文 count:要获取的日志条数

func (*Client) ACLLogReset added in v3.6.4

func (r *Client) ACLLogReset(ctx context.Context) (val string, err error)

ACLLogReset 重置 ACL 日志。ctx:上下文

func (*Client) Append

func (r *Client) Append(ctx context.Context, key string, value string) (val int64, err error)

Append 将字符串追加到key的值末尾 key: 键名 value: 要追加的字符串

func (*Client) BFAdd added in v3.8.19

func (r *Client) BFAdd(ctx context.Context, key string, element any) (val bool, err error)

BFAdd 添加元素到布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, element: 要添加的元素

func (*Client) BFCard added in v3.8.19

func (r *Client) BFCard(ctx context.Context, key string) (val int64, err error)

BFCard 获取布隆过滤器的元素数量 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFExists added in v3.8.19

func (r *Client) BFExists(ctx context.Context, key string, element any) (val bool, err error)

BFExists 检查元素是否存在于布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, element: 要检查的元素

func (*Client) BFInfo added in v3.8.19

func (r *Client) BFInfo(ctx context.Context, key string) (val redis.BFInfo, err error)

BFInfo 获取布隆过滤器的信息 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFInfoArg added in v3.8.19

func (r *Client) BFInfoArg(ctx context.Context, key, option string) (val redis.BFInfo, err error)

BFInfoArg 获取布隆过滤器的信息 ctx: 上下文, key: 布隆过滤器键名, option: 信息选项

func (*Client) BFInfoCapacity added in v3.8.19

func (r *Client) BFInfoCapacity(ctx context.Context, key string) (val redis.BFInfo, err error)

BFInfoCapacity 获取布隆过滤器的容量 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFInfoExpansion added in v3.8.19

func (r *Client) BFInfoExpansion(ctx context.Context, key string) (val redis.BFInfo, err error)

BFInfoExpansion 获取布隆过滤器的扩展 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFInfoFilters added in v3.8.19

func (r *Client) BFInfoFilters(ctx context.Context, key string) (val redis.BFInfo, err error)

BFInfoFilters 获取布隆过滤器的过滤器 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFInfoItems added in v3.8.19

func (r *Client) BFInfoItems(ctx context.Context, key string) (val redis.BFInfo, err error)

BFInfoItems 获取布隆过滤器的元素 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFInfoSize added in v3.8.19

func (r *Client) BFInfoSize(ctx context.Context, key string) (val redis.BFInfo, err error)

BFInfoSize 获取布隆过滤器的大小 ctx: 上下文, key: 布隆过滤器键名

func (*Client) BFInsert added in v3.8.19

func (r *Client) BFInsert(ctx context.Context, key string, options *redis.BFInsertOptions, elements ...any) (val []bool, err error)

BFInsert 插入元素到布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, options: 插入选项, elements: 要插入的元素

func (*Client) BFLoadChunk added in v3.8.19

func (r *Client) BFLoadChunk(ctx context.Context, key string, iterator int64, data any) (val string, err error)

BFLoadChunk 加载布隆过滤器的块 ctx: 上下文, key: 布隆过滤器键名, iterator: 迭代器, data: 数据块

func (*Client) BFMAdd added in v3.8.19

func (r *Client) BFMAdd(ctx context.Context, key string, elements ...any) (val []bool, err error)

BFMAdd 添加多个元素到布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, elements: 要添加的元素

func (*Client) BFMExists added in v3.8.19

func (r *Client) BFMExists(ctx context.Context, key string, elements ...any) (val []bool, err error)

BFMExists 检查多个元素是否存在于布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, elements: 要检查的元素

func (*Client) BFReserve added in v3.8.19

func (r *Client) BFReserve(ctx context.Context, key string, errorRate float64, capacity int64) (val string, err error)

BFReserve 创建布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, errorRate: 错误率, capacity: 容量

func (*Client) BFReserveExpansion added in v3.8.19

func (r *Client) BFReserveExpansion(ctx context.Context, key string, errorRate float64, capacity, expansion int64) (val string, err error)

BFReserveExpansion 创建布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, errorRate: 错误率, capacity: 容量, expansion: 扩展因子

func (*Client) BFReserveNonScaling added in v3.8.19

func (r *Client) BFReserveNonScaling(ctx context.Context, key string, errorRate float64, capacity int64) (val string, err error)

BFReserveNonScaling 创建布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, errorRate: 错误率, capacity: 容量

func (*Client) BFReserveWithArgs added in v3.8.19

func (r *Client) BFReserveWithArgs(ctx context.Context, key string, options *redis.BFReserveOptions) (val string, err error)

BFReserveWithArgs 创建布隆过滤器 ctx: 上下文, key: 布隆过滤器键名, options: 创建选项

func (*Client) BFScanDump added in v3.8.19

func (r *Client) BFScanDump(ctx context.Context, key string, iterator int64) (val redis.ScanDump, err error)

BFScanDump 获取布隆过滤器的迭代器 ctx: 上下文, key: 布隆过滤器键名, iterator: 迭代器

func (*Client) BLMPop added in v3.5.4

func (r *Client) BLMPop(ctx context.Context, timeout time.Duration, direction string, count int64, keys ...string) (key string, val []string, err error)

BLMPop 阻塞式弹出多个列表元素 ctx: 上下文, timeout: 超时时间, direction: 弹出方向(left/right), count: 弹出数量, keys: 要弹出的键列表

func (*Client) BLMove added in v3.2.31

func (r *Client) BLMove(ctx context.Context, source, destination, srcpos, destpos string, ts time.Duration) (val string, err error)

func (*Client) BLPop

func (r *Client) BLPop(ctx context.Context, timeout time.Duration, keys ...string) (val []string, err error)

BLPop 阻塞式弹出列表元素 ctx: 上下文, timeout: 超时时间, keys: 要弹出的键列表

func (*Client) BRPop

func (r *Client) BRPop(ctx context.Context, timeout time.Duration, keys ...string) (val []string, err error)

BRPop 阻塞式弹出列表尾部元素 ctx: 上下文, timeout: 超时时间, keys: 要弹出的键列表

func (*Client) BRPopLPush

func (r *Client) BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) (val string, err error)

BRPopLPush 阻塞式弹出并插入元素 ctx: 上下文, source: 源列表, destination: 目标列表, timeout: 超时时间

func (*Client) BZMPop added in v3.5.4

func (r *Client) BZMPop(ctx context.Context, timeout time.Duration, order string, count int64, keys ...string) (val string, ret []redis.Z, err error)

BZMPop 阻塞式从有序集合中弹出元素 ctx: 上下文 timeout: 超时时间 order: 排序方式 count: 弹出数量 keys: 一个或多个有序集合键

func (*Client) BZPopMax

func (r *Client) BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) (val *redis.ZWithKey, err error)

BZPopMax 阻塞式获取有序集合中分数最大的元素 ctx: 上下文 timeout: 超时时间 keys: 一个或多个有序集合键

func (*Client) BZPopMin

func (r *Client) BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) (val *redis.ZWithKey, err error)

BZPopMin 阻塞式获取有序集合中分数最小的元素 ctx: 上下文 timeout: 超时时间 keys: 一个或多个有序集合键

func (*Client) BgRewriteAOF

func (r *Client) BgRewriteAOF(ctx context.Context) (val string, err error)

BgRewriteAOF 异步重写AOF文件 ctx: 上下文

func (*Client) BgSave

func (r *Client) BgSave(ctx context.Context) (val string, err error)

BgSave 异步保存数据到磁盘 ctx: 上下文

func (*Client) BitCount

func (r *Client) BitCount(ctx context.Context, key string, bitCount *redis.BitCount) (val int64, err error)

BitCount 计算给定字符串中,被设置为 1 的比特位的数量。key: 键名, bitCount: 计数范围(start/end)。一般情况下,给定的整个字符串都会被进行计数,通过指定额外的 start 或 end 参数,可以让计数只在特定的位上进行。start 和 end 参数的设置和 GETRANGE 命令类似,都可以使用负数值:比如 -1 表示最后一个位,而 -2 表示倒数第二个位,以此类推。不存在的 key 被当成是空字符串来处理,因此对一个不存在的 key 进行 BITCOUNT 操作,结果为 0 。

func (*Client) BitField

func (r *Client) BitField(ctx context.Context, key string, args ...any) (val []int64, err error)

BitField 对 key 所储存的字符串值,获取指定偏移量上的位(bit)。key: 键名, args: 位域操作参数列表。

func (*Client) BitFieldRO added in v3.8.19

func (r *Client) BitFieldRO(ctx context.Context, key string, args ...any) (val []int64, err error)

BitFieldRO 对 key 所储存的字符串值,获取指定偏移量上的位(bit)。key: 键名, args: 位域操作参数列表。

func (*Client) BitOpAnd

func (r *Client) BitOpAnd(ctx context.Context, destKey string, keys ...string) (val int64, err error)

BitOpAnd 对一个或多个保存二进制位的字符串 key 进行位元操作,并将结果保存到 destKey 上。destKey: 目标键名, keys: 源键名列表。

func (*Client) BitOpNot

func (r *Client) BitOpNot(ctx context.Context, destKey string, key string) (val int64, err error)

BitOpNot 对一个保存二进制位的字符串 key 进行位非操作,并将结果保存到 destKey 上。destKey: 目标键名, key: 源键名。

func (*Client) BitOpOr

func (r *Client) BitOpOr(ctx context.Context, destKey string, keys ...string) (val int64, err error)

BitOpOr 对一个或多个保存二进制位的字符串 key 进行位元操作,并将结果保存到 destKey 上。destKey: 目标键名, keys: 源键名列表。

func (*Client) BitOpXor

func (r *Client) BitOpXor(ctx context.Context, destKey string, keys ...string) (val int64, err error)

BitOpXor 对一个或多个保存二进制位的字符串 key 进行位元操作,并将结果保存到 destKey 上。destKey: 目标键名, keys: 源键名列表。

func (*Client) BitPos

func (r *Client) BitPos(ctx context.Context, key string, bit int64, pos ...int64) (val int64, err error)

BitPos 返回字符串里面第一个被设置为1或者0的bit位。key: 键名, bit: 要查找的位值(0或1), pos: 可选起始位置。

func (*Client) BitPosSpan added in v3.6.12

func (r *Client) BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) (val int64, err error)

BitPosSpan 返回字符串里面第一个被设置为1或者0的bit位。key: 键名, bit: 要查找的位值(0或1), start: 起始位置, end: 结束位置, span: 范围类型。

func (*Client) CFAdd added in v3.8.19

func (r *Client) CFAdd(ctx context.Context, key string, element any) (val bool, err error)

CFAdd 添加元素到计数过滤器 ctx: 上下文, key: 计数过滤器键名, element: 要添加的元素

func (*Client) CFAddNX added in v3.8.19

func (r *Client) CFAddNX(ctx context.Context, key string, element any) (val bool, err error)

CFAddNX 添加元素到计数过滤器 ctx: 上下文, key: 计数过滤器键名, element: 要添加的元素

func (*Client) CFCount added in v3.8.19

func (r *Client) CFCount(ctx context.Context, key string, element any) (val int64, err error)

CFCount 获取计数过滤器的元素数量 ctx: 上下文, key: 计数过滤器键名, element: 要计数的元素

func (*Client) CFDel added in v3.8.19

func (r *Client) CFDel(ctx context.Context, key string, element any) (val bool, err error)

CFDel 删除计数过滤器的元素 ctx: 上下文, key: 计数过滤器键名, element: 要删除的元素

func (*Client) CFExists added in v3.8.19

func (r *Client) CFExists(ctx context.Context, key string, element any) (val bool, err error)

CFExists 检查元素是否存在于计数过滤器 ctx: 上下文, key: 计数过滤器键名, element: 要检查的元素

func (*Client) CFInfo added in v3.8.19

func (r *Client) CFInfo(ctx context.Context, key string) (val redis.CFInfo, err error)

CFInfo 获取计数过滤器的信息 ctx: 上下文, key: 计数过滤器键名

func (*Client) CFInsert added in v3.8.19

func (r *Client) CFInsert(ctx context.Context, key string, options *redis.CFInsertOptions, elements ...any) (val []bool, err error)

CFInsert 插入元素到计数过滤器 ctx: 上下文, key: 计数过滤器键名, options: 插入选项, elements: 要插入的元素

func (*Client) CFInsertNX added in v3.8.19

func (r *Client) CFInsertNX(ctx context.Context, key string, options *redis.CFInsertOptions, elements ...any) (val []int64, err error)

CFInsertNX 插入元素到计数过滤器 ctx: 上下文, key: 计数过滤器键名, options: 插入选项, elements: 要插入的元素

func (*Client) CFLoadChunk added in v3.8.19

func (r *Client) CFLoadChunk(ctx context.Context, key string, iterator int64, data any) (val string, err error)

CFLoadChunk 加载计数过滤器的块

func (*Client) CFMExists added in v3.8.19

func (r *Client) CFMExists(ctx context.Context, key string, elements ...any) (val []bool, err error)

CFMExists 检查多个元素是否存在于计数过滤器 ctx: 上下文, key: 计数过滤器键名, elements: 要检查的元素

func (*Client) CFReserve added in v3.8.19

func (r *Client) CFReserve(ctx context.Context, key string, capacity int64) (val string, err error)

CFReserve 创建计数过滤器 ctx: 上下文, key: 计数过滤器键名, capacity: 容量

func (*Client) CFReserveBucketSize added in v3.8.19

func (r *Client) CFReserveBucketSize(ctx context.Context, key string, capacity, bucketsize int64) (val string, err error)

CFReserveBucketSize 创建计数过滤器 ctx: 上下文, key: 计数过滤器键名, capacity: 容量, bucketsize: 桶大小

func (*Client) CFReserveExpansion added in v3.8.19

func (r *Client) CFReserveExpansion(ctx context.Context, key string, capacity, expansion int64) (val string, err error)

CFReserveExpansion 创建计数过滤器 ctx: 上下文, key: 计数过滤器键名, capacity: 容量, expansion: 扩展因子

func (*Client) CFReserveMaxIterations added in v3.8.19

func (r *Client) CFReserveMaxIterations(ctx context.Context, key string, capacity, maxiterations int64) (val string, err error)

CFReserveMaxIterations 创建计数过滤器 ctx: 上下文, key: 计数过滤器键名, capacity: 容量, maxiterations: 最大迭代次数

func (*Client) CFReserveWithArgs added in v3.8.19

func (r *Client) CFReserveWithArgs(ctx context.Context, key string, options *redis.CFReserveOptions) (val string, err error)

CFReserveWithArgs 创建计数过滤器 ctx: 上下文, key: 计数过滤器键名, options: 创建选项

func (*Client) CFScanDump added in v3.8.19

func (r *Client) CFScanDump(ctx context.Context, key string, iterator int64) (val redis.ScanDump, err error)

CFScanDump 获取计数过滤器的迭代器 ctx: 上下文, key: 计数过滤器键名, iterator: 迭代器

func (*Client) CMSIncrBy added in v3.8.19

func (r *Client) CMSIncrBy(ctx context.Context, key string, elements ...any) (val []int64, err error)

CMSIncrBy 增加元素到计数最小二乘 ctx: 上下文, key: 计数最小二乘键名, elements: 要增加的元素

func (*Client) CMSInfo added in v3.8.19

func (r *Client) CMSInfo(ctx context.Context, key string) (val redis.CMSInfo, err error)

CMSInfo 获取计数最小二乘的信息 ctx: 上下文, key: 计数最小二乘键名

func (*Client) CMSInitByDim added in v3.8.19

func (r *Client) CMSInitByDim(ctx context.Context, key string, width, height int64) (val string, err error)

CMSInitByDim 初始化计数最小二乘 ctx: 上下文, key: 计数最小二乘键名, width: 宽度, height: 高度

func (*Client) CMSInitByProb added in v3.8.19

func (r *Client) CMSInitByProb(ctx context.Context, key string, errorRate, probability float64) (val string, err error)

CMSInitByProb 初始化计数最小二乘 ctx: 上下文, key: 计数最小二乘键名, errorRate: 错误率, probability: 概率

func (*Client) CMSMerge added in v3.8.19

func (r *Client) CMSMerge(ctx context.Context, destkey string, sourceKeys ...string) (val string, err error)

CMSMerge 合并计数最小二乘 ctx: 上下文, destKey: 目标键名, sourceKeys: 源键名

func (*Client) CMSMergeWithWeight added in v3.8.19

func (r *Client) CMSMergeWithWeight(ctx context.Context, destkey string, sourceKeys map[string]int64) (val string, err error)

CMSMergeWithWeight 合并计数最小二乘 ctx: 上下文, destKey: 目标键名, sourceKeys: 源键名及其权重

func (*Client) CMSQuery added in v3.8.19

func (r *Client) CMSQuery(ctx context.Context, key string, elements ...any) (val []int64, err error)

CMSQuery 查询计数最小二乘 ctx: 上下文, key: 计数最小二乘键名, elements: 要查询的元素

func (*Client) ClientGetName

func (r *Client) ClientGetName(ctx context.Context) (val string, err error)

ClientGetName 获取客户端连接名称 ctx: 上下文

func (*Client) ClientID

func (r *Client) ClientID(ctx context.Context) (val int64, err error)

ClientID 获取客户端ID ctx: 上下文

func (*Client) ClientInfo added in v3.6.1

func (r *Client) ClientInfo(ctx context.Context) (val *redis.ClientInfo, err error)

ClientInfo 获取客户端详细信息 ctx: 上下文

func (*Client) ClientKill

func (r *Client) ClientKill(ctx context.Context, ipPort string) (val string, err error)

ClientKill 终止客户端连接 ctx: 上下文, ipPort: 客户端地址

func (*Client) ClientKillByFilter

func (r *Client) ClientKillByFilter(ctx context.Context, keys ...string) (val int64, err error)

ClientKillByFilter 根据条件终止客户端连接 ctx: 上下文, keys: 过滤条件

func (*Client) ClientList

func (r *Client) ClientList(ctx context.Context) (val string, err error)

ClientList 获取客户端连接列表 ctx: 上下文

func (*Client) ClientPause

func (r *Client) ClientPause(ctx context.Context, dur time.Duration) (val bool, err error)

ClientPause 暂停处理客户端命令 ctx: 上下文, dur: 暂停时间

func (*Client) ClientUnblock added in v3.2.31

func (r *Client) ClientUnblock(ctx context.Context, id int64) (val int64, err error)

ClientUnblock 解除客户端阻塞状态 ctx: 上下文, id: 客户端ID

func (*Client) ClientUnblockWithError added in v3.2.31

func (r *Client) ClientUnblockWithError(ctx context.Context, id int64) (val int64, err error)

ClientUnblockWithError 解除客户端阻塞状态并返回错误 ctx: 上下文, id: 客户端ID

func (*Client) ClientUnpause added in v3.2.31

func (r *Client) ClientUnpause(ctx context.Context) (val bool, err error)

ClientUnpause 恢复处理客户端命令 ctx: 上下文

func (*Client) ClusterAddSlots

func (r *Client) ClusterAddSlots(ctx context.Context, slots ...int) (val string, err error)

ClusterAddSlots 为当前节点分配新的哈希槽 ctx:上下文 slots:哈希槽列表

func (*Client) ClusterAddSlotsRange

func (r *Client) ClusterAddSlotsRange(ctx context.Context, min, max int) (val string, err error)

ClusterAddSlotsRange 为当前节点分配指定范围内的哈希槽 ctx:上下文 min:起始哈希槽 max:结束哈希槽

func (*Client) ClusterCountFailureReports

func (r *Client) ClusterCountFailureReports(ctx context.Context, nodeID string) (val int64, err error)

ClusterCountFailureReports 返回指定节点的故障报告数量 ctx:上下文 nodeID:节点ID

func (*Client) ClusterCountKeysInSlot

func (r *Client) ClusterCountKeysInSlot(ctx context.Context, slot int) (val int64, err error)

ClusterCountKeysInSlot 返回指定哈希槽中的key数量 ctx:上下文 slot:哈希槽

func (*Client) ClusterDelSlots

func (r *Client) ClusterDelSlots(ctx context.Context, slots ...int) (val string, err error)

ClusterDelSlots 删除指定哈希槽的绑定 ctx:上下文 slots:哈希槽列表

func (*Client) ClusterDelSlotsRange

func (r *Client) ClusterDelSlotsRange(ctx context.Context, min, max int) (val string, err error)

ClusterDelSlotsRange 删除指定范围内的哈希槽绑定 ctx:上下文 min:起始哈希槽 max:结束哈希槽

func (*Client) ClusterFailover

func (r *Client) ClusterFailover(ctx context.Context) (val string, err error)

ClusterFailover 强制从节点执行手动故障转移 ctx:上下文

func (*Client) ClusterForget

func (r *Client) ClusterForget(ctx context.Context, nodeID string) (val string, err error)

ClusterForget 从集群中移除指定节点 ctx:上下文 nodeID:节点ID

func (*Client) ClusterGetKeysInSlot

func (r *Client) ClusterGetKeysInSlot(ctx context.Context, slot, count int) (val []string, err error)

ClusterGetKeysInSlot 返回指定哈希槽中的key列表 ctx:上下文 slot:哈希槽 count:返回key的数量

func (*Client) ClusterInfo

func (r *Client) ClusterInfo(ctx context.Context) (val string, err error)

ClusterInfo 获取集群节点状态信息 ctx:上下文

func (*Client) ClusterKeySlot

func (r *Client) ClusterKeySlot(ctx context.Context, key string) (val int64, err error)

ClusterKeySlot 返回指定key的哈希槽 ctx:上下文 key:键名

func (r *Client) ClusterLinks(ctx context.Context) (val []redis.ClusterLink, err error)

ClusterLinks 获取集群节点间的链接信息 ctx:上下文

func (*Client) ClusterMeet

func (r *Client) ClusterMeet(ctx context.Context, host, port string) (val string, err error)

ClusterMeet 将新节点加入集群 ctx:上下文 host:主机地址 port:端口号

func (*Client) ClusterMyShardID added in v3.6.1

func (r *Client) ClusterMyShardID(ctx context.Context) (val string, err error)

ClusterMyShardID 获取当前节点的ID ctx:上下文

func (*Client) ClusterNodes

func (r *Client) ClusterNodes(ctx context.Context) (val string, err error)

ClusterNodes 获取集群节点信息 ctx:上下文

func (*Client) ClusterReplicate

func (r *Client) ClusterReplicate(ctx context.Context, nodeID string) (val string, err error)

ClusterReplicate 将当前节点配置为指定主节点的从节点 ctx:上下文 nodeID:主节点ID

func (*Client) ClusterResetHard

func (r *Client) ClusterResetHard(ctx context.Context) (val string, err error)

ClusterResetHard 硬重置集群节点(清除数据) ctx:上下文

func (*Client) ClusterResetSoft

func (r *Client) ClusterResetSoft(ctx context.Context) (val string, err error)

ClusterResetSoft 软重置集群节点(保留数据) ctx:上下文

func (*Client) ClusterSaveConfig

func (r *Client) ClusterSaveConfig(ctx context.Context) (val string, err error)

ClusterSaveConfig 强制将集群状态保存到磁盘 ctx:上下文

func (*Client) ClusterShards added in v3.5.4

func (r *Client) ClusterShards(ctx context.Context) (val []redis.ClusterShard, err error)

ClusterShards 获取集群分片信息 ctx:上下文

func (*Client) ClusterSlaves

func (r *Client) ClusterSlaves(ctx context.Context, nodeID string) (val []string, err error)

ClusterSlaves 列出指定主节点的从节点列表 ctx:上下文 nodeID:主节点ID

func (*Client) ClusterSlots

func (r *Client) ClusterSlots(ctx context.Context) (val []redis.ClusterSlot, err error)

ClusterSlots 获取集群节点的映射数组 ctx:上下文

func (*Client) Command

func (r *Client) Command(ctx context.Context) (val map[string]*redis.CommandInfo, err error)

Command 获取所有Redis命令的详细信息 ctx: 上下文

func (*Client) CommandGetKeys added in v3.5.4

func (r *Client) CommandGetKeys(ctx context.Context, commands ...any) (val []string, err error)

CommandGetKeys 获取命令对应的键 ctx: 上下文, commands: 命令列表

func (*Client) CommandGetKeysAndFlags added in v3.5.4

func (r *Client) CommandGetKeysAndFlags(ctx context.Context, commands ...any) (val []redis.KeyFlags, err error)

CommandGetKeysAndFlags 获取命令对应的键及标志 ctx: 上下文, commands: 命令列表

func (*Client) CommandList added in v3.5.4

func (r *Client) CommandList(ctx context.Context, filter *redis.FilterBy) (val []string, err error)

CommandList 获取Redis命令列表 ctx: 上下文, filter: 过滤器

func (*Client) ConfigGet

func (r *Client) ConfigGet(ctx context.Context, parameter string) (val map[string]string, err error)

ConfigGet 获取配置参数 ctx: 上下文, parameter: 参数名

func (*Client) ConfigResetStat

func (r *Client) ConfigResetStat(ctx context.Context) (val string, err error)

ConfigResetStat 重置统计信息 ctx: 上下文

func (*Client) ConfigRewrite

func (r *Client) ConfigRewrite(ctx context.Context) (val string, err error)

ConfigRewrite 重写配置文件 ctx: 上下文

func (*Client) ConfigSet

func (r *Client) ConfigSet(ctx context.Context, parameter, value string) (val string, err error)

ConfigSet 设置配置参数 ctx: 上下文, parameter: 参数名, value: 参数值

func (*Client) Copy added in v3.2.31

func (r *Client) Copy(ctx context.Context, sourceKey, destKey string, db int, replace bool) (val int64, err error)

Copy 复制key sourceKey: 源key destKey: 目标key db: 目标数据库 replace: 是否替换

func (*Client) DBSize

func (r *Client) DBSize(ctx context.Context) (val int64, err error)

DBSize 获取当前数据库键数量 ctx: 上下文

func (*Client) DebugObject

func (r *Client) DebugObject(ctx context.Context, key string) (val string, err error)

DebugObject 获取键的调试信息 ctx: 上下文, key: 键名

func (*Client) Decr

func (r *Client) Decr(ctx context.Context, key string) (val int64, err error)

Decr 将key的值减1 key: 键名

func (*Client) DecrBy

func (r *Client) DecrBy(ctx context.Context, key string, value int64) (val int64, err error)

DecrBy 将key的值减去指定数值 key: 键名 value: 要减去的数值

func (*Client) Del

func (r *Client) Del(ctx context.Context, keys ...string) (val int64, err error)

Del 删除给定的一个或多个key keys: 要删除的key列表

func (*Client) Dump

func (r *Client) Dump(ctx context.Context, key string) (val string, err error)

Dump 序列化给定key key: 要序列化的key

func (*Client) Echo

func (r *Client) Echo(ctx context.Context, message any) (val string, err error)

Echo 返回输入的消息 ctx: 上下文, message: 要返回的消息

func (*Client) Eval

func (r *Client) Eval(ctx context.Context, script string, keys []string, args ...any) (val any, err error)

Eval 执行Lua脚本 ctx:上下文 script:Lua脚本 keys:键列表 args:参数列表

func (*Client) EvalRO added in v3.2.31

func (r *Client) EvalRO(ctx context.Context, script string, keys []string, args ...any) (val any, err error)

EvalRO 以只读模式执行Lua脚本 ctx:上下文 script:Lua脚本 keys:键列表 args:参数列表

func (*Client) EvalSha

func (r *Client) EvalSha(ctx context.Context, sha1 string, keys []string, args ...any) (val any, err error)

EvalSha 通过SHA1执行Lua脚本 ctx:上下文 sha1:脚本SHA1值 keys:键列表 args:参数列表

func (*Client) EvalShaRO added in v3.2.31

func (r *Client) EvalShaRO(ctx context.Context, sha1 string, keys []string, args ...any) (val any, err error)

EvalShaRO 以只读模式通过SHA1执行Lua脚本 ctx:上下文 sha1:脚本SHA1值 keys:键列表 args:参数列表

func (*Client) Exists

func (r *Client) Exists(ctx context.Context, key ...string) (val bool, err error)

Exists 检查给定key是否存在 key: 要检查的key

func (*Client) Expire

func (r *Client) Expire(ctx context.Context, key string, expiration time.Duration) (val bool, err error)

Expire 为给定key设置生存时间 key: 要设置的key expiration: 生存时间

func (*Client) ExpireAt

func (r *Client) ExpireAt(ctx context.Context, key string, tm time.Time) (val bool, err error)

ExpireAt 以UNIX时间戳格式设置key的过期时间 key: 要设置的key tm: 过期时间

func (*Client) ExpireGT added in v3.2.31

func (r *Client) ExpireGT(ctx context.Context, key string, tm time.Duration) (val bool, err error)

ExpireGT 仅在当前生存时间大于给定值时设置 key: 要设置的key tm: 生存时间

func (*Client) ExpireLT added in v3.2.31

func (r *Client) ExpireLT(ctx context.Context, key string, tm time.Duration) (val bool, err error)

ExpireLT 仅在当前生存时间小于给定值时设置 key: 要设置的key tm: 生存时间

func (*Client) ExpireNX added in v3.2.31

func (r *Client) ExpireNX(ctx context.Context, key string, tm time.Duration) (val bool, err error)

ExpireNX 仅在key不存在时设置生存时间 key: 要设置的key tm: 生存时间

func (*Client) ExpireTime added in v3.5.4

func (r *Client) ExpireTime(ctx context.Context, key string) (val time.Duration, err error)

ExpireTime 返回key的剩余生存时间 key: 要查询的key

func (*Client) ExpireXX added in v3.2.31

func (r *Client) ExpireXX(ctx context.Context, key string, tm time.Duration) (val bool, err error)

ExpireXX 仅在key存在时设置生存时间 key: 要设置的key tm: 生存时间

func (*Client) FCall added in v3.5.4

func (r *Client) FCall(ctx context.Context, function string, keys []string, args ...any) (val any, err error)

FCall 调用Redis函数 ctx:上下文 function:函数名称 keys:键列表 args:参数列表

func (*Client) FCallRO added in v3.6.1

func (r *Client) FCallRO(ctx context.Context, function string, keys []string, args ...any) (val any, err error)

FCallRO 以只读模式调用Redis函数 ctx:上下文 function:函数名称 keys:键列表 args:参数列表

func (*Client) FCallRo added in v3.5.4

func (r *Client) FCallRo(ctx context.Context, function string, keys []string, args ...any) (val any, err error)

FCallRo 以只读模式调用Redis函数 ctx:上下文 function:函数名称 keys:键列表 args:参数列表

func (*Client) FTAggregate added in v3.6.20

func (r *Client) FTAggregate(ctx context.Context, index, query string) (val map[string]any, err error)

FTAggregate 执行聚合查询 ctx: 上下文, index: 索引名称, query: 查询语句

func (*Client) FTAggregateWithArgs added in v3.6.20

func (r *Client) FTAggregateWithArgs(ctx context.Context, index, query string, options *redis.FTAggregateOptions) (val *redis.FTAggregateResult, err error)

FTAggregateWithArgs 执行聚合查询 ctx: 上下文, index: 索引名称, query: 查询语句, options: 聚合选项

func (*Client) FTAliasAdd added in v3.6.20

func (r *Client) FTAliasAdd(ctx context.Context, index, alias string) (val string, err error)

FTAliasAdd 添加别名 ctx: 上下文, index: 索引名称, alias: 别名

func (*Client) FTAliasDel added in v3.6.20

func (r *Client) FTAliasDel(ctx context.Context, alias string) (val string, err error)

FTAliasDel 删除别名 ctx: 上下文, alias: 别名

func (*Client) FTAliasUpdate added in v3.6.20

func (r *Client) FTAliasUpdate(ctx context.Context, index, alias string) (val string, err error)

FTAliasUpdate 更新别名 ctx: 上下文, index: 索引名称, alias: 别名

func (*Client) FTAlter added in v3.6.20

func (r *Client) FTAlter(ctx context.Context, index string, skipInitialScan bool, definition []any) (val string, err error)

FTAlter 修改索引 ctx: 上下文, index: 索引名称, skipInitialScan: 是否跳过初始扫描, definition: 定义

func (*Client) FTConfigGet added in v3.6.20

func (r *Client) FTConfigGet(ctx context.Context, option string) (val map[string]any, err error)

FTConfigGet 获取配置 ctx: 上下文, option: 配置项

func (*Client) FTConfigSet added in v3.6.20

func (r *Client) FTConfigSet(ctx context.Context, option string, value any) (val string, err error)

FTConfigSet 设置配置 ctx: 上下文, option: 配置项, value: 配置值

func (*Client) FTCreate added in v3.6.20

func (r *Client) FTCreate(ctx context.Context, index string, options *redis.FTCreateOptions, schema ...*redis.FieldSchema) (val string, err error)

FTCreate 创建索引 ctx: 上下文, index: 索引名称, options: 创建选项, schema: 字段模式

func (*Client) FTCursorDel added in v3.6.20

func (r *Client) FTCursorDel(ctx context.Context, index string, cursorId int) (val string, err error)

FTCursorDel 删除游标 ctx: 上下文, index: 索引名称, cursorId: 游标ID

func (*Client) FTCursorRead added in v3.6.20

func (r *Client) FTCursorRead(ctx context.Context, index string, cursorId, count int) (val map[string]any, err error)

FTCursorRead 读取游标 ctx: 上下文, index: 索引名称, cursorId: 游标ID, count: 读取数量

func (*Client) FTDictAdd added in v3.6.20

func (r *Client) FTDictAdd(ctx context.Context, dict string, term ...any) (val int64, err error)

FTDictAdd 添加字典 ctx: 上下文, dict: 字典名称, term: 术语列表

func (*Client) FTDictDel added in v3.6.20

func (r *Client) FTDictDel(ctx context.Context, dict string, term ...any) (val int64, err error)

FTDictDel 删除字典 ctx: 上下文, dict: 字典名称, term: 术语列表

func (*Client) FTDictDump added in v3.6.20

func (r *Client) FTDictDump(ctx context.Context, dict string) (val []string, err error)

FTDictDump 导出字典 ctx: 上下文, dict: 字典名称

func (*Client) FTDropIndex added in v3.6.20

func (r *Client) FTDropIndex(ctx context.Context, index string) (val string, err error)

FTDropIndex 删除索引 ctx: 上下文, index: 索引名称

func (*Client) FTDropIndexWithArgs added in v3.6.20

func (r *Client) FTDropIndexWithArgs(ctx context.Context, index string, options *redis.FTDropIndexOptions) (val string, err error)

FTDropIndexWithArgs 删除索引 ctx: 上下文, index: 索引名称, options: 删除选项

func (*Client) FTExplain added in v3.6.20

func (r *Client) FTExplain(ctx context.Context, index, query string) (val string, err error)

FTExplain 解释查询 ctx: 上下文, index: 索引名称, query: 查询语句

func (*Client) FTExplainWithArgs added in v3.6.20

func (r *Client) FTExplainWithArgs(ctx context.Context, index, query string, options *redis.FTExplainOptions) (val string, err error)

FTExplainWithArgs 解释查询 ctx: 上下文, index: 索引名称, query: 查询语句, options: 解释选项

func (*Client) FTInfo added in v3.6.20

func (r *Client) FTInfo(ctx context.Context, index string) (val redis.FTInfoResult, err error)

FTInfo 获取索引信息 ctx: 上下文, index: 索引名称

func (*Client) FTSearch added in v3.6.20

func (r *Client) FTSearch(ctx context.Context, index, query string) (val redis.FTSearchResult, err error)

FTSearch 执行搜索 ctx: 上下文, index: 索引名称, query: 查询语句

func (*Client) FTSearchWithArgs added in v3.6.20

func (r *Client) FTSearchWithArgs(ctx context.Context, index, query string, options *redis.FTSearchOptions) (val redis.FTSearchResult, err error)

FTSearchWithArgs 执行搜索 ctx: 上下文, index: 索引名称, query: 查询语句, options: 搜索选项

func (*Client) FTSpellCheck added in v3.6.20

func (r *Client) FTSpellCheck(ctx context.Context, index, query string) (val []redis.SpellCheckResult, err error)

FTSpellCheck 拼写检查 ctx: 上下文, index: 索引名称, query: 查询语句

func (*Client) FTSpellCheckWithArgs added in v3.6.20

func (r *Client) FTSpellCheckWithArgs(ctx context.Context, index, query string, options *redis.FTSpellCheckOptions) (val []redis.SpellCheckResult, err error)

FTSpellCheckWithArgs 拼写检查 ctx: 上下文, index: 索引名称, query: 查询语句, options: 拼写检查选项

func (*Client) FTSynDump added in v3.6.20

func (r *Client) FTSynDump(ctx context.Context, index string) (val []redis.FTSynDumpResult, err error)

FTSynDump 导出同义词 ctx: 上下文, index: 索引名称

func (*Client) FTSynUpdate added in v3.6.20

func (r *Client) FTSynUpdate(ctx context.Context, index string, synGroupId any, terms []any) (val string, err error)

FTSynUpdate 更新同义词 ctx: 上下文, index: 索引名称, synGroupId: 同义词组ID, terms: 术语列表

func (*Client) FTSynUpdateWithArgs added in v3.6.20

func (r *Client) FTSynUpdateWithArgs(ctx context.Context, index string, synGroupId any, options *redis.FTSynUpdateOptions, terms []any) (val string, err error)

FTSynUpdateWithArgs 更新同义词 ctx: 上下文, index: 索引名称, synGroupId: 同义词组ID, options: 更新选项, terms: 术语列表

func (*Client) FTTagVals added in v3.6.20

func (r *Client) FTTagVals(ctx context.Context, index, field string) (val []string, err error)

FTTagVals 获取标签值 ctx: 上下文, index: 索引名称, field: 字段名称

func (*Client) FT_List added in v3.8.19

func (r *Client) FT_List(ctx context.Context) (val []string, err error)

FT_List 获取所有索引的名称 ctx: 上下文

func (*Client) FlushAll

func (r *Client) FlushAll(ctx context.Context) (val string, err error)

FlushAll 删除所有数据库的所有键 ctx: 上下文

func (*Client) FlushAllAsync

func (r *Client) FlushAllAsync(ctx context.Context) (val string, err error)

FlushAllAsync 异步删除所有数据库的所有键 ctx: 上下文

func (*Client) FlushDB

func (r *Client) FlushDB(ctx context.Context) (val string, err error)

FlushDB 删除当前数据库的所有键 ctx: 上下文

func (*Client) FlushDBAsync

func (r *Client) FlushDBAsync(ctx context.Context) (val string, err error)

FlushDBAsync 异步删除当前数据库的所有键 ctx: 上下文

func (*Client) FunctionDelete added in v3.5.4

func (r *Client) FunctionDelete(ctx context.Context, libName string) (val string, err error)

FunctionDelete 删除Redis函数 ctx:上下文 libName:函数库名称

func (*Client) FunctionDump added in v3.5.4

func (r *Client) FunctionDump(ctx context.Context) (val string, err error)

FunctionDump 导出Redis函数 ctx:上下文

func (*Client) FunctionFlush added in v3.5.4

func (r *Client) FunctionFlush(ctx context.Context) (val string, err error)

FunctionFlush 清空所有Redis函数 ctx:上下文

func (*Client) FunctionFlushAsync added in v3.5.4

func (r *Client) FunctionFlushAsync(ctx context.Context) (val string, err error)

FunctionFlushAsync 异步清空所有Redis函数 ctx:上下文

func (*Client) FunctionKill added in v3.5.4

func (r *Client) FunctionKill(ctx context.Context) (val string, err error)

FunctionKill 终止正在运行的Redis函数 ctx:上下文

func (*Client) FunctionList added in v3.5.4

func (r *Client) FunctionList(ctx context.Context, q redis.FunctionListQuery) (val []redis.Library, err error)

FunctionList 列出所有Redis函数 ctx:上下文 q:查询条件

func (*Client) FunctionLoad added in v3.5.4

func (r *Client) FunctionLoad(ctx context.Context, code string) (val string, err error)

FunctionLoad 加载Redis函数 ctx:上下文 code:函数代码

func (*Client) FunctionLoadReplace added in v3.5.4

func (r *Client) FunctionLoadReplace(ctx context.Context, code string) (val string, err error)

FunctionLoadReplace 替换已存在的Redis函数 ctx:上下文 code:函数代码

func (*Client) FunctionRestore added in v3.5.4

func (r *Client) FunctionRestore(ctx context.Context, libDump string) (val string, err error)

FunctionRestore 恢复Redis函数 ctx:上下文 libDump:函数库数据

func (*Client) FunctionStats added in v3.5.4

func (r *Client) FunctionStats(ctx context.Context) (val redis.FunctionStats, err error)

FunctionStats 获取Redis函数统计信息 ctx:上下文

func (*Client) GeoAdd

func (r *Client) GeoAdd(ctx context.Context, key string, geoLocation ...*redis.GeoLocation) (val int64, err error)

GeoAdd 将指定的地理空间位置(纬度、经度、名称)添加到指定的key中

func (*Client) GeoDist

func (r *Client) GeoDist(ctx context.Context, key string, member1, member2, unit string) (val float64, err error)

GeoDist 返回两个给定位置之间的距离 ctx: 上下文 key: 键名 member1: 位置1 member2: 位置2 unit: 距离单位(m|km|ft|mi)

func (*Client) GeoHash

func (r *Client) GeoHash(ctx context.Context, key string, members ...string) (val []string, err error)

GeoHash 返回一个或多个位置元素的 Geohash 表示 ctx: 上下文 key: 键名 members: 位置元素列表

func (*Client) GeoPos

func (r *Client) GeoPos(ctx context.Context, key string, members ...string) (val []*redis.GeoPos, err error)

GeoPos 从key里返回所有给定位置元素的位置(经度和纬度)

func (*Client) GeoRadius

func (r *Client) GeoRadius(ctx context.Context, key string, longitude, latitude float64, query *redis.GeoRadiusQuery) (val []redis.GeoLocation, err error)

GeoRadius 以给定的经纬度为中心, 找出某一半径内的元素

func (*Client) GeoRadiusByMember

func (r *Client) GeoRadiusByMember(ctx context.Context, key, member string, query *redis.GeoRadiusQuery) (val []redis.GeoLocation, err error)

GeoRadiusByMember 找出位于指定范围内的元素,中心点是由给定的位置元素决定 ctx: 上下文 key: 键名 member: 位置元素 query: 查询条件

func (*Client) GeoRadiusByMemberStore

func (r *Client) GeoRadiusByMemberStore(ctx context.Context, key, member string, query *redis.GeoRadiusQuery) (val int64, err error)

GeoRadiusByMemberStore 找出位于指定范围内的元素,中心点是由给定的位置元素决定

func (*Client) GeoRadiusStore

func (r *Client) GeoRadiusStore(ctx context.Context, key string, longitude, latitude float64, query *redis.GeoRadiusQuery) (val int64, err error)

GeoRadiusStore 找出位于指定范围内的元素,中心点是由给定的经纬度决定 ctx: 上下文 key: 键名 longitude: 经度 latitude: 纬度 query: 查询条件

func (*Client) GeoSearch added in v3.2.31

func (r *Client) GeoSearch(ctx context.Context, key string, q *redis.GeoSearchQuery) (val []string, err error)

GeoSearch 在指定key中搜索地理空间位置 ctx: 上下文 key: 键名 q: 搜索查询条件

func (*Client) GeoSearchLocation added in v3.2.31

func (r *Client) GeoSearchLocation(ctx context.Context, key string, q *redis.GeoSearchLocationQuery) (val []redis.GeoLocation, err error)

GeoSearchLocation 在指定key中搜索地理空间位置并返回位置信息 ctx: 上下文 key: 键名 q: 搜索查询条件

func (*Client) GeoSearchStore added in v3.2.31

func (r *Client) GeoSearchStore(ctx context.Context, key, store string, q *redis.GeoSearchStoreQuery) (val int64, err error)

GeoSearchStore 在指定key中搜索地理空间位置并将结果存储到另一个key中 ctx: 上下文 key: 源键名 store: 目标键名 q: 搜索查询条件

func (*Client) Get

func (r *Client) Get(ctx context.Context, key string) (val string, err error)

Get 获取key的值 key: 键名

func (*Client) GetBit

func (r *Client) GetBit(ctx context.Context, key string, offset int64) (val int64, err error)

GetBit 对 key 所储存的字符串值,获取指定偏移量上的位(bit)。key: 键名, offset: 位偏移量。当 offset 比字符串值的长度大,或者 key 不存在时,返回 0 。

func (*Client) GetClientConfig added in v3.4.2

func (o *Client) GetClientConfig() *redis.Options

GetClientConfig 获取单节点配置

func (*Client) GetClusterClientConfig added in v3.4.2

func (o *Client) GetClusterClientConfig() *redis.ClusterOptions

GetClusterClientConfig 获取集群配置

func (*Client) GetDel added in v3.2.31

func (r *Client) GetDel(ctx context.Context, key string) (val string, err error)

GetDel 获取key的值并删除 key: 键名

func (*Client) GetEx added in v3.2.31

func (r *Client) GetEx(ctx context.Context, key string, ts time.Duration) (val string, err error)

GetEx 获取key的值并设置过期时间 key: 键名 ts: 过期时间

func (*Client) GetFailoverClientConfig added in v3.4.2

func (o *Client) GetFailoverClientConfig() *redis.FailoverOptions

GetFailoverClient 获取哨兵配置

func (*Client) GetRange

func (r *Client) GetRange(ctx context.Context, key string, start, end int64) (val string, err error)

GetRange 获取key的值的子字符串 key: 键名 start: 起始位置 end: 结束位置

func (*Client) GetRingClientConfig added in v3.4.2

func (o *Client) GetRingClientConfig() *redis.RingOptions

GetRingClientConfig 获取分片配置

func (*Client) GetSet

func (r *Client) GetSet(ctx context.Context, key string, value any) (val string, err error)

GetSet 设置key的值并返回旧值 key: 键名 value: 新值

func (*Client) HDel

func (r *Client) HDel(ctx context.Context, key string, fields ...string) (val int64, err error)

HDel 删除哈希表key中的一个或多个指定域,不存在的域将被忽略 ctx: 上下文 key: 哈希表键 fields: 要删除的域

func (*Client) HExists

func (r *Client) HExists(ctx context.Context, key, field string) (val bool, err error)

HExists 查看哈希表key中给定域是否存在 ctx: 上下文 key: 哈希表键 field: 要检查的域

func (*Client) HExpire added in v3.8.19

func (r *Client) HExpire(ctx context.Context, key string, expiration time.Duration, fields ...string) (val []int64, err error)

HExpire 设置哈希表key中一个或多个域的过期时间 ctx: 上下文 key: 哈希表键 expiration: 过期时间 fields: 要设置过期时间的域 如果指定的域不存在,那么命令将被忽略。

func (*Client) HExpireAt added in v3.8.19

func (r *Client) HExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) (val []int64, err error)

HExpireAt 设置哈希表key中域的过期时间戳 ctx: 上下文 key: 哈希表键 tm: 过期时间戳 fields: 要设置过期时间的域

func (*Client) HExpireAtWithArgs added in v3.8.19

func (r *Client) HExpireAtWithArgs(ctx context.Context, key string, tm time.Time, expirationArgs redis.HExpireArgs, fields ...string) (val []int64, err error)

HExpireAtWithArgs 使用额外参数设置哈希表key中域的过期时间戳 ctx: 上下文 key: 哈希表键 tm: 过期时间戳 expirationArgs: 额外参数 fields: 要设置过期时间的域

func (*Client) HExpireTime added in v3.8.19

func (r *Client) HExpireTime(ctx context.Context, key string, fields ...string) (val []int64, err error)

HExpireTime 返回哈希表key中域的过期时间 ctx: 上下文 key: 哈希表键 fields: 要查询的域

func (*Client) HExpireWithArgs added in v3.8.19

func (r *Client) HExpireWithArgs(ctx context.Context, key string, expiration time.Duration, expirationArgs redis.HExpireArgs, fields ...string) (val []int64, err error)

HExpireWithArgs 使用额外参数设置哈希表key中域的过期时间 ctx: 上下文 key: 哈希表键 expiration: 过期时间 expirationArgs: 额外参数 fields: 要设置过期时间的域

func (*Client) HGet

func (r *Client) HGet(ctx context.Context, key, field string) (val string, err error)

HGet 返回哈希表key中给定域的值 ctx: 上下文 key: 哈希表键 field: 要获取值的域

func (*Client) HGetAll

func (r *Client) HGetAll(ctx context.Context, key string) (val map[string]string, err error)

HGetAll 返回哈希表key中所有的域和值 ctx: 上下文 key: 哈希表键 在返回值里,紧跟每个域名(field name)之后是域的值(value),所以返回值的长度是哈希表大小的两倍。

func (*Client) HIncrBy

func (r *Client) HIncrBy(ctx context.Context, key string, field string, incr int64) (val int64, err error)

HIncrBy 为哈希表key中的域的值加上增量 ctx: 上下文 key: 哈希表键 field: 要增加值的域 incr: 增量值 增量也可以为负数,相当于对给定域进行减法操作。 如果 key 不存在,一个新的哈希表被创建并执行 HINCRBY 命令。 如果域 field 不存在,那么在执行命令前,域的值被初始化为 0 。 对一个储存字符串值的域 field 执行 HINCRBY 命令将造成一个错误。 本操作的值被限制在 64 位(bit)有符号数字表示之内。

func (*Client) HIncrByFloat

func (r *Client) HIncrByFloat(ctx context.Context, key string, field string, incr float64) (val float64, err error)

HIncrByFloat 为哈希表key中的域加上浮点数增量 ctx: 上下文 key: 哈希表键 field: 要增加值的域 incr: 浮点数增量 如果哈希表中没有域 field ,那么 HINCRBYFLOAT 会先将域 field 的值设为 0 ,然后再执行加法操作。 如果键 key 不存在,那么 HINCRBYFLOAT 会先创建一个哈希表,再创建域 field ,最后再执行加法操作。

func (*Client) HKeys

func (r *Client) HKeys(ctx context.Context, key string) (val []string, err error)

HKeys 返回哈希表key中的所有域 ctx: 上下文 key: 哈希表键

func (*Client) HLen

func (r *Client) HLen(ctx context.Context, key string) (val int64, err error)

HLen 返回哈希表key中域的数量 ctx: 上下文 key: 哈希表键

func (*Client) HMGet

func (r *Client) HMGet(ctx context.Context, key string, fields ...string) (val []any, err error)

HMGet 返回哈希表key中一个或多个给定域的值 ctx: 上下文 key: 哈希表键 fields: 要获取值的域 如果给定的域不存在于哈希表,那么返回一个 nil 值。 因为不存在的 key 被当作一个空哈希表来处理,所以对一个不存在的 key 进行 HMGET 操作将返回一个只带有 nil 值的表。

func (*Client) HMSet

func (r *Client) HMSet(ctx context.Context, key string, value ...any) (val bool, err error)

HMSet 同时将多个field-value对设置到哈希表key中 ctx: 上下文 key: 哈希表键 value: 要设置的键值对 此命令会覆盖哈希表中已存在的域。 如果 key 不存在,一个空哈希表被创建并执行 HMSET 操作。

func (*Client) HPExpire added in v3.8.19

func (r *Client) HPExpire(ctx context.Context, key string, expiration time.Duration, fields ...string) (val []int64, err error)

HPExpire 以毫秒为单位设置哈希表key中域的过期时间 ctx: 上下文 key: 哈希表键 expiration: 过期时间 fields: 要设置过期时间的域

func (*Client) HPExpireAt added in v3.8.19

func (r *Client) HPExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) (val []int64, err error)

HPExpireAt 以毫秒为单位设置哈希表key中域的过期时间戳 ctx: 上下文 key: 哈希表键 tm: 过期时间戳 fields: 要设置过期时间的域

func (*Client) HPExpireAtWithArgs added in v3.8.19

func (r *Client) HPExpireAtWithArgs(ctx context.Context, key string, tm time.Time, expirationArgs redis.HExpireArgs, fields ...string) (val []int64, err error)

HPExpireAtWithArgs 使用额外参数以毫秒为单位设置哈希表key中域的过期时间戳 ctx: 上下文 key: 哈希表键 tm: 过期时间戳 expirationArgs: 额外参数 fields: 要设置过期时间的域

func (*Client) HPExpireTime added in v3.8.19

func (r *Client) HPExpireTime(ctx context.Context, key string, fields ...string) (val []int64, err error)

HPExpireTime 以毫秒为单位返回哈希表key中域的过期时间 ctx: 上下文 key: 哈希表键 fields: 要查询的域

func (*Client) HPExpireWithArgs added in v3.8.19

func (r *Client) HPExpireWithArgs(ctx context.Context, key string, expiration time.Duration, expirationArgs redis.HExpireArgs, fields ...string) (val []int64, err error)

HPExpireWithArgs 使用额外参数以毫秒为单位设置哈希表key中域的过期时间 ctx: 上下文 key: 哈希表键 expiration: 过期时间 expirationArgs: 额外参数 fields: 要设置过期时间的域

func (*Client) HPTTL added in v3.8.19

func (r *Client) HPTTL(ctx context.Context, key string, fields ...string) (val []int64, err error)

HPTTL 以毫秒为单位返回哈希表key中域的剩余生存时间 ctx: 上下文 key: 哈希表键 fields: 要查询的域

func (*Client) HPersist added in v3.8.19

func (r *Client) HPersist(ctx context.Context, key string, fields ...string) (val []int64, err error)

HPersist 移除哈希表key中域的过期时间 ctx: 上下文 key: 哈希表键 fields: 要移除过期时间的域

func (*Client) HRandField added in v3.2.31

func (r *Client) HRandField(ctx context.Context, key string, count int) (val []string, err error)

HRandField 从哈希表key中随机获取指定数量的域 ctx: 上下文 key: 哈希表键 count: 要获取的域数量

func (*Client) HRandFieldWithValues added in v3.2.31

func (r *Client) HRandFieldWithValues(ctx context.Context, key string, count int) (val []redis.KeyValue, err error)

HRandFieldWithValues 从哈希表key中随机获取指定数量的域及其值 ctx: 上下文 key: 哈希表键 count: 要获取的域数量

func (*Client) HScan

func (r *Client) HScan(ctx context.Context, key string, cursorIn uint64, match string, count int64) (val []string, cursor uint64, err error)

HScan 迭代哈希表中的键值对 ctx: 上下文 key: 哈希表键 cursorIn: 游标 match: 匹配模式 count: 每次迭代返回的数量

func (*Client) HScanNoValues added in v3.8.19

func (r *Client) HScanNoValues(ctx context.Context, key string, cursor uint64, match string, count int64) (val []string, cursorOut uint64, err error)

HScanNoValues 迭代哈希表中的键(不返回值) ctx: 上下文 key: 哈希表键 cursor: 游标 match: 匹配模式 count: 每次迭代返回的数量

func (*Client) HSet

func (r *Client) HSet(ctx context.Context, key string, value ...any) (val int64, err error)

HSet 将哈希表key中的域的值设为指定值 ctx: 上下文 key: 哈希表键 value: 要设置的值 如果 key 不存在,一个新的哈希表被创建并进行 HSET 操作。 如果域 field 已经存在于哈希表中,旧值将被覆盖。

func (*Client) HSetNX

func (r *Client) HSetNX(ctx context.Context, key string, field string, value any) (val bool, err error)

HSetNX 当域不存在时将哈希表key中的域的值设置为指定值 ctx: 上下文 key: 哈希表键 field: 要设置的域 value: 要设置的值 若域 field 已经存在,该操作无效。 如果 key 不存在,一个新哈希表被创建并执行 HSETNX 命令。

func (*Client) HTTL added in v3.8.19

func (r *Client) HTTL(ctx context.Context, key string, fields ...string) (val []int64, err error)

HTTL 返回哈希表key中域的剩余生存时间 ctx: 上下文 key: 哈希表键 fields: 要查询的域

func (*Client) HVals

func (r *Client) HVals(ctx context.Context, key string) (val []string, err error)

HVals 返回哈希表key中所有域的值 ctx: 上下文 key: 哈希表键

func (*Client) Incr

func (r *Client) Incr(ctx context.Context, key string) (val int64, err error)

Incr 将key的值加1 key: 键名

func (*Client) IncrBy

func (r *Client) IncrBy(ctx context.Context, key string, value int64) (val int64, err error)

IncrBy 将key的值增加指定数值 key: 键名 value: 要增加的数值

func (*Client) IncrByFloat

func (r *Client) IncrByFloat(ctx context.Context, key string, value float64) (val float64, err error)

IncrByFloat 将key的值增加指定浮点数 key: 键名 value: 要增加的浮点数

func (*Client) Info

func (r *Client) Info(ctx context.Context, section ...string) (val string, err error)

Info 获取服务器信息 ctx: 上下文, section: 信息模块

func (*Client) JSONArrAppend added in v3.8.19

func (r *Client) JSONArrAppend(ctx context.Context, key, path string, values ...any) (val []int64, err error)

JSONArrAppend 向JSON数组追加元素 ctx: 上下文, key: Redis键名, path: JSON路径, values: 要追加的值

func (*Client) JSONArrIndex added in v3.8.19

func (r *Client) JSONArrIndex(ctx context.Context, key, path string, value ...any) (val []int64, err error)

JSONArrIndex 查找JSON数组中元素的索引 ctx: 上下文, key: Redis键名, path: JSON路径, value: 要查找的值

func (*Client) JSONArrIndexWithArgs added in v3.8.19

func (r *Client) JSONArrIndexWithArgs(ctx context.Context, key, path string, options *redis.JSONArrIndexArgs, value ...any) (val []int64, err error)

JSONArrIndexWithArgs 带参数查找JSON数组中元素的索引 ctx: 上下文, key: Redis键名, path: JSON路径, options: 查找选项, value: 要查找的值

func (*Client) JSONArrInsert added in v3.8.19

func (r *Client) JSONArrInsert(ctx context.Context, key, path string, index int64, values ...any) (val []int64, err error)

JSONArrInsert 向JSON数组插入元素 ctx: 上下文, key: Redis键名, path: JSON路径, index: 插入位置, values: 要插入的值

func (*Client) JSONArrLen added in v3.8.19

func (r *Client) JSONArrLen(ctx context.Context, key, path string) (val []int64, err error)

JSONArrLen 获取JSON数组长度 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONArrPop added in v3.8.19

func (r *Client) JSONArrPop(ctx context.Context, key, path string, index int) (val []string, err error)

JSONArrPop 从JSON数组弹出元素 ctx: 上下文, key: Redis键名, path: JSON路径, index: 弹出位置

func (*Client) JSONArrTrim added in v3.8.19

func (r *Client) JSONArrTrim(ctx context.Context, key, path string) (val []int64, err error)

JSONArrTrim 修剪JSON数组 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONArrTrimWithArgs added in v3.8.19

func (r *Client) JSONArrTrimWithArgs(ctx context.Context, key, path string, options *redis.JSONArrTrimArgs) (val []int64, err error)

JSONArrTrimWithArgs 带参数修剪JSON数组 ctx: 上下文, key: Redis键名, path: JSON路径, options: 修剪选项

func (*Client) JSONClear added in v3.8.19

func (r *Client) JSONClear(ctx context.Context, key, path string) (val int64, err error)

JSONClear 清除JSON值 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONDebugMemory added in v3.8.19

func (r *Client) JSONDebugMemory(ctx context.Context, key, path string) (val int64, err error)

JSONDebugMemory 调试JSON内存使用 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONDel added in v3.8.19

func (r *Client) JSONDel(ctx context.Context, key, path string) (val int64, err error)

JSONDel 删除JSON值 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONForget added in v3.8.19

func (r *Client) JSONForget(ctx context.Context, key, path string) (val int64, err error)

JSONForget 删除JSON值(别名) ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONGet added in v3.8.19

func (r *Client) JSONGet(ctx context.Context, key string, paths ...string) (val string, err error)

JSONGet 获取JSON值 ctx: 上下文, key: Redis键名, paths: JSON路径

func (*Client) JSONGetWithArgs added in v3.8.19

func (r *Client) JSONGetWithArgs(ctx context.Context, key string, options *redis.JSONGetArgs, paths ...string) (val string, err error)

JSONGetWithArgs 带参数获取JSON值 ctx: 上下文, key: Redis键名, options: 获取选项, paths: JSON路径

func (*Client) JSONMGet added in v3.8.19

func (r *Client) JSONMGet(ctx context.Context, path string, keys ...string) (val []any, err error)

JSONMGet 批量获取JSON值 ctx: 上下文, path: JSON路径, keys: Redis键名列表

func (*Client) JSONMSet added in v3.8.19

func (r *Client) JSONMSet(ctx context.Context, params ...any) (val string, err error)

JSONMSet 批量设置JSON值 ctx: 上下文, params: 设置参数

func (*Client) JSONMSetArgs added in v3.8.19

func (r *Client) JSONMSetArgs(ctx context.Context, docs []redis.JSONSetArgs) (val string, err error)

JSONMSetArgs 批量设置JSON值(带参数) ctx: 上下文, docs: JSON设置参数列表

func (*Client) JSONMerge added in v3.8.19

func (r *Client) JSONMerge(ctx context.Context, key, path string, value string) (val string, err error)

JSONMerge 合并JSON值 ctx: 上下文, key: Redis键名, path: JSON路径, value: 要合并的值

func (*Client) JSONNumIncrBy added in v3.8.19

func (r *Client) JSONNumIncrBy(ctx context.Context, key, path string, value float64) (val string, err error)

JSONNumIncrBy 增加JSON数值 ctx: 上下文, key: Redis键名, path: JSON路径, value: 增加值

func (*Client) JSONObjKeys added in v3.8.19

func (r *Client) JSONObjKeys(ctx context.Context, key, path string) (val []any, err error)

JSONObjKeys 获取JSON对象键名列表 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONObjLen added in v3.8.19

func (r *Client) JSONObjLen(ctx context.Context, key, path string) (val []*int64, err error)

JSONObjLen 获取JSON对象长度 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONSet added in v3.8.19

func (r *Client) JSONSet(ctx context.Context, key, path string, value any) (val string, err error)

JSONSet 设置JSON值 ctx: 上下文, key: Redis键名, path: JSON路径, value: 要设置的值

func (*Client) JSONSetMode added in v3.8.19

func (r *Client) JSONSetMode(ctx context.Context, key, path string, value any, mode string) (val string, err error)

JSONSetMode 带模式设置JSON值 ctx: 上下文, key: Redis键名, path: JSON路径, value: 要设置的值, mode: 设置模式

func (*Client) JSONStrAppend added in v3.8.19

func (r *Client) JSONStrAppend(ctx context.Context, key, path, value string) (val []*int64, err error)

JSONStrAppend 向JSON字符串追加内容 ctx: 上下文, key: Redis键名, path: JSON路径, value: 要追加的值

func (*Client) JSONStrLen added in v3.8.19

func (r *Client) JSONStrLen(ctx context.Context, key, path string) (val []*int64, err error)

JSONStrLen 获取JSON字符串长度 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONToggle added in v3.8.19

func (r *Client) JSONToggle(ctx context.Context, key, path string) (val []*int64, err error)

JSONToggle 切换JSON布尔值 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) JSONType added in v3.8.19

func (r *Client) JSONType(ctx context.Context, key, path string) (val []any, err error)

JSONType 获取JSON值类型 ctx: 上下文, key: Redis键名, path: JSON路径

func (*Client) Keys

func (r *Client) Keys(ctx context.Context, key string) (val []string, err error)

Keys 查找符合模式的key key: 要匹配的模式

func (*Client) LCS added in v3.5.4

func (r *Client) LCS(ctx context.Context, q *redis.LCSQuery) (val *redis.LCSMatch, err error)

LCS 计算两个字符串的最长公共子序列 q: 查询参数

func (*Client) LIndex

func (r *Client) LIndex(ctx context.Context, key string, index int64) (val string, err error)

LIndex 获取列表指定位置的元素 ctx: 上下文, key: 列表键, index: 元素索引

func (*Client) LInsert

func (r *Client) LInsert(ctx context.Context, key string, op string, pivot, value any) (val int64, err error)

LInsert 在列表中插入元素 ctx: 上下文, key: 列表键, op: 插入位置(BEFORE/AFTER), pivot: 参考元素, value: 要插入的值

func (*Client) LInsertAfter

func (r *Client) LInsertAfter(ctx context.Context, key string, pivot, value any) (val int64, err error)

LInsertAfter 在参考元素后插入值 ctx: 上下文, key: 列表键, pivot: 参考元素, value: 要插入的值

func (*Client) LInsertBefore

func (r *Client) LInsertBefore(ctx context.Context, key string, pivot, value any) (val int64, err error)

LInsertBefore 在参考元素前插入值 ctx: 上下文, key: 列表键, pivot: 参考元素, value: 要插入的值

func (*Client) LLen

func (r *Client) LLen(ctx context.Context, key string) (val int64, err error)

LLen 获取列表长度 ctx: 上下文, key: 列表键

func (*Client) LMPop added in v3.5.4

func (r *Client) LMPop(ctx context.Context, direction string, count int64, keys ...string) (key string, val []string, err error)

LMPop 弹出多个列表元素 ctx: 上下文, direction: 弹出方向(left/right), count: 弹出数量, keys: 要弹出的键列表

func (*Client) LMove added in v3.2.31

func (r *Client) LMove(ctx context.Context, source, destination, srcpos, destpos string) (val string, err error)

func (*Client) LPop

func (r *Client) LPop(ctx context.Context, key string) (val string, err error)

LPop 弹出列表头元素 ctx: 上下文, key: 列表键

func (*Client) LPopCount added in v3.2.31

func (r *Client) LPopCount(ctx context.Context, key string, count int) (val []string, err error)

LPopCount 弹出多个列表头元素 ctx: 上下文, key: 列表键, count: 弹出数量

func (*Client) LPos added in v3.2.31

func (r *Client) LPos(ctx context.Context, key string, value string, args redis.LPosArgs) (val int64, err error)

func (*Client) LPosCount added in v3.2.31

func (r *Client) LPosCount(ctx context.Context, key string, value string, count int64, args redis.LPosArgs) (val []int64, err error)

func (*Client) LPush

func (r *Client) LPush(ctx context.Context, key string, values ...any) (val int64, err error)

LPush 在列表头部插入元素 ctx: 上下文, key: 列表键, values: 要插入的值

func (*Client) LPushX

func (r *Client) LPushX(ctx context.Context, key string, value any) (val int64, err error)

LPushX 仅在列表存在时在头部插入元素 ctx: 上下文, key: 列表键, value: 要插入的值

func (*Client) LRange

func (r *Client) LRange(ctx context.Context, key string, start, stop int64) (val []string, err error)

LRange 获取列表指定范围的元素 ctx: 上下文, key: 列表键, start: 起始索引, stop: 结束索引

func (*Client) LRem

func (r *Client) LRem(ctx context.Context, key string, count int64, value any) (val int64, err error)

LRem 移除列表中指定值的元素 ctx: 上下文, key: 列表键, count: 移除数量, value: 要移除的值

func (*Client) LSet

func (r *Client) LSet(ctx context.Context, key string, index int64, value any) (val string, err error)

LSet 设置列表指定位置的元素 ctx: 上下文, key: 列表键, index: 元素索引, value: 要设置的值

func (*Client) LTrim

func (r *Client) LTrim(ctx context.Context, key string, start, stop int64) (val string, err error)

LTrim 修剪列表只保留指定范围的元素 ctx: 上下文, key: 列表键, start: 起始索引, stop: 结束索引

func (*Client) LastSave

func (r *Client) LastSave(ctx context.Context) (val int64, err error)

LastSave 获取最后一次保存时间 ctx: 上下文

func (*Client) MGet

func (r *Client) MGet(ctx context.Context, keys ...string) (val []any, err error)

MGet 获取多个key的值 keys: 键名列表

func (*Client) MSet

func (r *Client) MSet(ctx context.Context, values ...any) (val string, err error)

MSet 设置多个key-value对 values: 键值对列表

func (*Client) MSetNX

func (r *Client) MSetNX(ctx context.Context, values ...any) (val bool, err error)

MSetNX 当所有key都不存在时设置多个key-value对 values: 键值对列表

func (*Client) MemoryUsage

func (r *Client) MemoryUsage(ctx context.Context, key string, samples ...int) (val int64, err error)

MemoryUsage 获取键的内存使用情况 ctx: 上下文, key: 键名, samples: 采样次数

func (*Client) Migrate

func (r *Client) Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) (val string, err error)

Migrate 将key迁移到其他实例 host: 目标主机 port: 目标端口 key: 要迁移的key db: 目标数据库 timeout: 超时时间

func (*Client) ModuleLoadex added in v3.6.1

func (r *Client) ModuleLoadex(ctx context.Context, conf *redis.ModuleLoadexConfig) (val string, err error)

ModuleLoadex 加载Redis模块 ctx: 上下文, conf: 模块配置

func (*Client) Move

func (r *Client) Move(ctx context.Context, key string, db int) (val bool, err error)

Move 将key移动到其他数据库 key: 要移动的key db: 目标数据库

func (*Client) ObjectEncoding

func (r *Client) ObjectEncoding(ctx context.Context, key string) (val string, err error)

ObjectEncoding 返回key的内部编码格式 key: 要查询的key

func (*Client) ObjectFreq added in v3.8.19

func (r *Client) ObjectFreq(ctx context.Context, key string) (val int64, err error)

ObjectFreq 返回key引用对象的频率 key: 要查询的key

func (*Client) ObjectIdleTime

func (r *Client) ObjectIdleTime(ctx context.Context, key string) (val time.Duration, err error)

ObjectIdleTime 返回key的空转时间 key: 要查询的key

func (*Client) ObjectRefCount

func (r *Client) ObjectRefCount(ctx context.Context, key string) (val int64, err error)

ObjectRefCount 返回key的引用计数 key: 要查询的key

func (*Client) PExpire

func (r *Client) PExpire(ctx context.Context, key string, expiration time.Duration) (val bool, err error)

PExpire 以毫秒为单位设置key生存时间 key: 要设置的key expiration: 生存时间

func (*Client) PExpireAt

func (r *Client) PExpireAt(ctx context.Context, key string, tm time.Time) (val bool, err error)

PExpireAt 以毫秒为单位设置key过期时间戳 key: 要设置的key tm: 过期时间

func (*Client) PExpireTime added in v3.5.4

func (r *Client) PExpireTime(ctx context.Context, key string) (val time.Duration, err error)

func (*Client) PFAdd

func (r *Client) PFAdd(ctx context.Context, key string, els ...any) (val int64, err error)

PFAdd 将指定元素添加到HyperLogLog key: HyperLogLog键名, els: 要添加的元素列表

func (*Client) PFCount

func (r *Client) PFCount(ctx context.Context, keys ...string) (val int64, err error)

PFCount 返回HyperlogLog观察到的集合的近似基数。 keys: 要查询的HyperLogLog键名列表

func (*Client) PFMerge

func (r *Client) PFMerge(ctx context.Context, dest string, keys ...string) (val string, err error)

PFMerge N个不同的HyperLogLog合并为一个。 dest: 目标HyperLogLog键名, keys: 要合并的HyperLogLog键名列表

func (*Client) PTTL

func (r *Client) PTTL(ctx context.Context, key string) (val time.Duration, err error)

PTTL 以毫秒为单位返回key剩余生存时间 key: 要查询的key

func (*Client) Persist

func (r *Client) Persist(ctx context.Context, key string) (val bool, err error)

Persist 移除key的生存时间 key: 要操作的key

func (*Client) Ping

func (r *Client) Ping(ctx context.Context) (val string, err error)

Ping 测试与Redis服务器的连接 ctx: 上下文

func (*Client) Pipeline

func (r *Client) Pipeline() (val redis.Pipeliner, err error)

Pipeline 获取Redis管道 无参数

func (*Client) Pipelined

func (r *Client) Pipelined(ctx context.Context, fn func(redis.Pipeliner) error) (val []redis.Cmder, err error)

Pipelined 执行管道操作 ctx: 上下文, fn: 管道操作函数

func (*Client) PubSubChannels

func (r *Client) PubSubChannels(ctx context.Context, pattern string) (val []string, err error)

PubSubChannels 获取匹配模式的活跃频道列表 ctx: 上下文 pattern: 频道匹配模式

func (*Client) PubSubNumPat

func (r *Client) PubSubNumPat(ctx context.Context) (val int64, err error)

PubSubNumPat 获取模式订阅的数量 ctx: 上下文

func (*Client) PubSubNumSub

func (r *Client) PubSubNumSub(ctx context.Context, channels ...string) (val map[string]int64, err error)

PubSubNumSub 获取指定频道的订阅数量 ctx: 上下文 channels: 要查询的频道列表

func (*Client) PubSubShardChannels added in v3.2.31

func (r *Client) PubSubShardChannels(ctx context.Context, pattern string) (val []string, err error)

PubSubShardChannels 获取匹配模式的活跃分片频道列表 ctx: 上下文 pattern: 频道匹配模式

func (*Client) PubSubShardNumSub added in v3.2.31

func (r *Client) PubSubShardNumSub(ctx context.Context, channels ...string) (val map[string]int64, err error)

PubSubShardNumSub 获取指定分片频道的订阅数量 ctx: 上下文 channels: 要查询的分片频道列表

func (*Client) Publish

func (r *Client) Publish(ctx context.Context, channel, message string) (val int64, err error)

Publish 将信息发送到指定的频道 ctx: 上下文 channel: 频道名称 message: 要发送的消息

func (*Client) Quit

func (r *Client) Quit(ctx context.Context) (val string, err error)

Quit 关闭客户端连接 ctx: 上下文

func (*Client) RPop

func (r *Client) RPop(ctx context.Context, key string) (val string, err error)

RPop 弹出列表尾部元素 ctx: 上下文, key: 列表键

func (*Client) RPopCount added in v3.2.31

func (r *Client) RPopCount(ctx context.Context, key string, count int) (val []string, err error)

RPopCount 弹出多个列表尾部元素 ctx: 上下文, key: 列表键, count: 弹出数量

func (*Client) RPopLPush

func (r *Client) RPopLPush(ctx context.Context, source, destination string) (val string, err error)

RPopLPush 弹出尾部元素并插入到另一个列表 ctx: 上下文, source: 源列表, destination: 目标列表

func (*Client) RPush

func (r *Client) RPush(ctx context.Context, key string, values ...any) (val int64, err error)

RPush 在列表尾部插入元素 ctx: 上下文, key: 列表键, values: 要插入的值

func (*Client) RPushX

func (r *Client) RPushX(ctx context.Context, key string, value any) (val int64, err error)

RPushX 仅在列表存在时在尾部插入元素 ctx: 上下文, key: 列表键, value: 要插入的值

func (*Client) RandomKey

func (r *Client) RandomKey(ctx context.Context) (val string, err error)

RandomKey 随机返回一个key

func (*Client) ReadOnly

func (r *Client) ReadOnly(ctx context.Context) (val string, err error)

ReadOnly 将当前连接设置为只读模式(针对从节点) ctx:上下文

func (*Client) ReadWrite

func (r *Client) ReadWrite(ctx context.Context) (val string, err error)

ReadWrite 将当前连接设置为读写模式(针对从节点) ctx:上下文

func (*Client) Rename

func (r *Client) Rename(ctx context.Context, key, newkey string) (val string, err error)

Rename 重命名key key: 原key名 newkey: 新key名

func (*Client) RenameNX

func (r *Client) RenameNX(ctx context.Context, key, newkey string) (val bool, err error)

RenameNX 仅在newkey不存在时重命名key key: 原key名 newkey: 新key名

func (*Client) Restore

func (r *Client) Restore(ctx context.Context, key string, ttl time.Duration, value string) (val string, err error)

Restore 反序列化值并与key关联 key: 目标key ttl: 生存时间 value: 序列化值

func (*Client) RestoreReplace

func (r *Client) RestoreReplace(ctx context.Context, key string, ttl time.Duration, value string) (val string, err error)

RestoreReplace -> Restore

func (*Client) SAdd

func (r *Client) SAdd(ctx context.Context, key string, members ...any) (val int64, err error)

SAdd 向集合添加元素 key:集合键名 members:要添加的元素

func (*Client) SCard

func (r *Client) SCard(ctx context.Context, key string) (val int64, err error)

SCard 获取集合元素数量 key:集合键名

func (*Client) SDiff

func (r *Client) SDiff(ctx context.Context, keys ...string) (val []string, err error)

SDiff 获取集合差集 keys:要比较的集合键名

func (*Client) SDiffStore

func (r *Client) SDiffStore(ctx context.Context, destination string, keys ...string) (val int64, err error)

SDiffStore 获取并存储集合差集 destination:目标集合键名 keys:要比较的集合键名

func (*Client) SInter

func (r *Client) SInter(ctx context.Context, keys ...string) (val []string, err error)

SInter 获取集合交集 keys:要比较的集合键名

func (*Client) SInterCard added in v3.2.31

func (r *Client) SInterCard(ctx context.Context, limit int64, keys ...string) (val int64, err error)

SInterCard 获取集合交集元素数量 limit:最大返回数量 keys:要比较的集合键名

func (*Client) SInterStore

func (r *Client) SInterStore(ctx context.Context, destination string, keys ...string) (val int64, err error)

SInterStore 获取并存储集合交集 destination:目标集合键名 keys:要比较的集合键名

func (*Client) SIsMember

func (r *Client) SIsMember(ctx context.Context, key string, member any) (val bool, err error)

SIsMember 判断元素是否在集合中 key:集合键名 member:要判断的元素

func (*Client) SMIsMember added in v3.6.12

func (r *Client) SMIsMember(ctx context.Context, key string, members ...any) (val []bool, err error)

SMIsMember 批量判断元素是否在集合中 key:集合键名 members:要判断的元素列表

func (*Client) SMembers

func (r *Client) SMembers(ctx context.Context, key string) (val []string, err error)

SMembers 获取集合所有元素 key:集合键名

func (*Client) SMembersMap

func (r *Client) SMembersMap(ctx context.Context, key string) (val map[string]struct{}, err error)

SMembersMap 获取集合所有元素到map key:集合键名

func (*Client) SMove

func (r *Client) SMove(ctx context.Context, source, destination string, member any) (val bool, err error)

SMove 移动集合元素 source:源集合键名 destination:目标集合键名 member:要移动的元素

func (*Client) SPop

func (r *Client) SPop(ctx context.Context, key string) (val string, err error)

SPop 移除并返回随机元素 key:集合键名

func (*Client) SPopN

func (r *Client) SPopN(ctx context.Context, key string, count int64) (val []string, err error)

SPopN 移除并返回多个随机元素 key:集合键名 count:要移除的元素数量

func (*Client) SPublish added in v3.2.31

func (r *Client) SPublish(ctx context.Context, channel, message string) (val int64, err error)

SPublish 将信息发送到指定的频道 ctx: 上下文 channel: 频道名称 message: 要发送的消息

func (*Client) SRandMember

func (r *Client) SRandMember(ctx context.Context, key string) (val string, err error)

SRandMember 获取随机元素 key:集合键名

func (*Client) SRandMemberN

func (r *Client) SRandMemberN(ctx context.Context, key string, count int64) (val []string, err error)

SRandMemberN 获取多个随机元素 key:集合键名 count:要获取的元素数量

func (*Client) SRem

func (r *Client) SRem(ctx context.Context, key string, members ...any) (val int64, err error)

SRem 移除集合元素 key:集合键名 members:要移除的元素

func (*Client) SScan

func (r *Client) SScan(ctx context.Context, key string, cursorIn uint64, match string, count int64) (val *redis.ScanCmd, err error)

SScan 扫描集合元素 key:集合键名 cursorIn:游标 match:匹配模式 count:每次扫描数量

func (*Client) SUnion

func (r *Client) SUnion(ctx context.Context, keys ...string) (val []string, err error)

SUnion 获取集合并集 keys:要合并的集合键名

func (*Client) SUnionStore

func (r *Client) SUnionStore(ctx context.Context, destination string, keys ...string) (val int64, err error)

SUnionStore 获取并存储集合并集 destination:目标集合键名 keys:要合并的集合键名

func (*Client) Save

func (r *Client) Save(ctx context.Context) (val string, err error)

Save 同步保存数据到磁盘 ctx: 上下文

func (*Client) Scan

func (r *Client) Scan(ctx context.Context, cursorIn uint64, match string, count int64) (val []string, cursor uint64, err error)

Scan 增量迭代key cursorIn: 起始游标 match: 匹配模式 count: 每次返回数量

func (*Client) ScanIterator added in v3.5.0

func (r *Client) ScanIterator(ctx context.Context, cursorIn uint64, match string, count int64) (val *redis.ScanIterator, err error)

ScanIterator 增量迭代key并返回迭代器 cursorIn: 起始游标 match: 匹配模式 count: 每次返回数量

func (*Client) ScanType added in v3.2.31

func (r *Client) ScanType(ctx context.Context, cursorIn uint64, match string, count int64, keyType string) (val []string, cursor uint64, err error)

ScanType 增量迭代key并返回指定类型的key cursorIn: 起始游标 match: 匹配模式 count: 每次返回数量 keyType: key类型

func (*Client) ScriptExists

func (r *Client) ScriptExists(ctx context.Context, hashes ...string) (val []bool, err error)

ScriptExists 检查脚本是否存在于缓存中 ctx:上下文 hashes:脚本SHA1值列表

func (*Client) ScriptFlush

func (r *Client) ScriptFlush(ctx context.Context) (val string, err error)

ScriptFlush 清空脚本缓存 ctx:上下文

func (*Client) ScriptKill

func (r *Client) ScriptKill(ctx context.Context) (val string, err error)

ScriptKill 终止正在运行的Lua脚本 ctx:上下文

func (*Client) ScriptLoad

func (r *Client) ScriptLoad(ctx context.Context, script string) (val string, err error)

ScriptLoad 加载脚本到缓存但不执行 ctx:上下文 script:Lua脚本

func (*Client) Set

func (r *Client) Set(ctx context.Context, key string, value any, expiration time.Duration) (val string, err error)

Set 设置key的值 key: 键名 value: 值 expiration: 过期时间

func (*Client) SetArgs added in v3.2.31

func (r *Client) SetArgs(ctx context.Context, key string, value any, a redis.SetArgs) (val string, err error)

SetArgs 设置key的值并指定额外参数 key: 键名 value: 值 a: 额外参数

func (*Client) SetBit

func (r *Client) SetBit(ctx context.Context, key string, offset int64, value int) (val int64, err error)

SetBit 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。key: 键名, offset: 位偏移量, value: 要设置的值(0或1)。当 key 不存在时,自动生成一个新的字符串值。字符串会进行伸展(grown)以确保它可以将 value 保存在指定的偏移量上。当字符串值进行伸展时,空白位置以 0 填充。offset 参数必须大于或等于 0 ,小于 2^32 (bit 映射被限制在 512 MB 之内)。

func (*Client) SetEx added in v3.2.31

func (r *Client) SetEx(ctx context.Context, key string, value any, expiration time.Duration) (val string, err error)

SetEx 设置key的值并指定过期时间 key: 键名 value: 值 expiration: 过期时间

func (*Client) SetNX

func (r *Client) SetNX(ctx context.Context, key string, value any, expiration time.Duration) (val bool, err error)

SetNX 当key不存在时设置值 key: 键名 value: 值 expiration: 过期时间

func (*Client) SetRange

func (r *Client) SetRange(ctx context.Context, key string, offset int64, value string) (val int64, err error)

SetRange 从指定位置覆写key的值 key: 键名 offset: 偏移量 value: 新值

func (*Client) SetXX

func (r *Client) SetXX(ctx context.Context, key string, value any, expiration time.Duration) (val bool, err error)

SetXX 当key存在时设置值 key: 键名 value: 值 expiration: 过期时间

func (*Client) Shutdown

func (r *Client) Shutdown(ctx context.Context) (val string, err error)

Shutdown 关闭服务器 ctx: 上下文

func (*Client) ShutdownNoSave

func (r *Client) ShutdownNoSave(ctx context.Context) (val string, err error)

ShutdownNoSave 不保存数据直接关闭服务器 ctx: 上下文

func (*Client) ShutdownSave

func (r *Client) ShutdownSave(ctx context.Context) (val string, err error)

ShutdownSave 保存数据并关闭服务器 ctx: 上下文

func (*Client) SlaveOf

func (r *Client) SlaveOf(ctx context.Context, host, port string) (val string, err error)

SlaveOf 设置主从复制 ctx: 上下文, host: 主机地址, port: 端口号

func (*Client) SlowLogGet added in v3.2.31

func (r *Client) SlowLogGet(ctx context.Context, num int64) (val []redis.SlowLog, err error)

SlowLogGet 获取慢查询日志 ctx: 上下文, num: 日志条数

func (*Client) Sort

func (r *Client) Sort(ctx context.Context, key string, sort *redis.Sort) (val []string, err error)

Sort 对key中的元素进行排序 key: 要排序的key sort: 排序参数

func (*Client) SortInterfaces

func (r *Client) SortInterfaces(ctx context.Context, key string, sort *redis.Sort) (val []any, err error)

SortInterfaces -> Sort

func (*Client) SortRO added in v3.2.31

func (r *Client) SortRO(ctx context.Context, key string, sort *redis.Sort) (val []string, err error)

func (*Client) SortStore

func (r *Client) SortStore(ctx context.Context, key, store string, sort *redis.Sort) (val int64, err error)

SortStore -> Sort

func (*Client) StrLen

func (r *Client) StrLen(ctx context.Context, key string) (val int64, err error)

StrLen 获取key的值的长度 key: 键名

func (*Client) TDigestAdd added in v3.8.19

func (r *Client) TDigestAdd(ctx context.Context, key string, elements ...float64) (val string, err error)

TDigestAdd 添加元素到TDigest ctx: 上下文, key: TDigest键名, elements: 要添加的元素

func (*Client) TDigestByRank added in v3.8.19

func (r *Client) TDigestByRank(ctx context.Context, key string, rank ...uint64) (val []float64, err error)

TDigestByRank 根据排名获取TDigest值 ctx: 上下文, key: TDigest键名, rank: 排名

func (*Client) TDigestByRevRank added in v3.8.19

func (r *Client) TDigestByRevRank(ctx context.Context, key string, rank ...uint64) (val []float64, err error)

TDigestByRevRank 根据反向排名获取TDigest值 ctx: 上下文, key: TDigest键名, rank: 反向排名

func (*Client) TDigestCDF added in v3.8.19

func (r *Client) TDigestCDF(ctx context.Context, key string, elements ...float64) (val []float64, err error)

TDigestCDF 获取TDigest的累积分布函数值 ctx: 上下文, key: TDigest键名, elements: 要查询的值

func (*Client) TDigestCreate added in v3.8.19

func (r *Client) TDigestCreate(ctx context.Context, key string) (val string, err error)

TDigestCreate 创建TDigest ctx: 上下文, key: TDigest键名

func (*Client) TDigestCreateWithCompression added in v3.8.19

func (r *Client) TDigestCreateWithCompression(ctx context.Context, key string, compression int64) (val string, err error)

TDigestCreateWithCompression 创建TDigest ctx: 上下文, key: TDigest键名, compression: 压缩参数

func (*Client) TDigestInfo added in v3.8.19

func (r *Client) TDigestInfo(ctx context.Context, key string) (val redis.TDigestInfo, err error)

TDigestInfo 获取TDigest的信息 ctx: 上下文, key: TDigest键名

func (*Client) TDigestMax added in v3.8.19

func (r *Client) TDigestMax(ctx context.Context, key string) (val float64, err error)

TDigestMax 获取TDigest的最大值 ctx: 上下文, key: TDigest键名

func (*Client) TDigestMerge added in v3.8.19

func (r *Client) TDigestMerge(ctx context.Context, destkey string, options *redis.TDigestMergeOptions, sourceKeys ...string) (val string, err error)

TDigestMerge 合并TDigest ctx: 上下文, destKey: 目标键名, options: 合并选项, sourceKeys: 源键名

func (*Client) TDigestMin added in v3.8.19

func (r *Client) TDigestMin(ctx context.Context, key string) (val float64, err error)

TDigestMin 获取TDigest的最小值 ctx: 上下文, key: TDigest键名

func (*Client) TDigestQuantile added in v3.8.19

func (r *Client) TDigestQuantile(ctx context.Context, key string, elements ...float64) (val []float64, err error)

TDigestQuantile 获取TDigest的分位数 ctx: 上下文, key: TDigest键名, elements: 分位数值

func (*Client) TDigestRank added in v3.8.19

func (r *Client) TDigestRank(ctx context.Context, key string, values ...float64) (val []int64, err error)

TDigestRank 获取TDigest的排名 ctx: 上下文, key: TDigest键名, values: 要查询的值

func (*Client) TDigestReset added in v3.8.19

func (r *Client) TDigestReset(ctx context.Context, key string) (val string, err error)

TDigestReset 重置TDigest ctx: 上下文, key: TDigest键名

func (*Client) TDigestRevRank added in v3.8.19

func (r *Client) TDigestRevRank(ctx context.Context, key string, values ...float64) (val []int64, err error)

TDigestRevRank 获取TDigest的反向排名 ctx: 上下文, key: TDigest键名, values: 要查询的值

func (*Client) TDigestTrimmedMean added in v3.8.19

func (r *Client) TDigestTrimmedMean(ctx context.Context, key string, lowCutQuantile, highCutQuantile float64) (val float64, err error)

TDigestTrimmedMean 获取TDigest的修剪均值 ctx: 上下文, key: TDigest键名, lowCutQuantile: 下分位数, highCutQuantile: 上分位数

func (*Client) TFCall added in v3.6.12

func (r *Client) TFCall(ctx context.Context, libName, funcName string, numKeys int) (val any, err error)

TFCall 调用 Redis 实例中的 Lua 函数 ctx: 上下文, libName: 库名称, funcName: 函数名称, numKeys: 键数量

func (*Client) TFCallASYNC added in v3.6.12

func (r *Client) TFCallASYNC(ctx context.Context, libName, funcName string, numKeys int) (val any, err error)

TFCallASYNC 异步调用 Redis 实例中的 Lua 函数 ctx: 上下文, libName: 库名称, funcName: 函数名称, numKeys: 键数量

func (*Client) TFCallASYNCArgs added in v3.6.12

func (r *Client) TFCallASYNCArgs(ctx context.Context, libName, funcName string, numKeys int, options *redis.TFCallOptions) (val any, err error)

TFCallASYNCArgs 异步调用 Redis 实例中的 Lua 函数 ctx: 上下文, libName: 库名称, funcName: 函数名称, numKeys: 键数量, options: 调用选项

func (*Client) TFCallArgs added in v3.6.12

func (r *Client) TFCallArgs(ctx context.Context, libName, funcName string, numKeys int, options *redis.TFCallOptions) (val any, err error)

TFCallArgs 调用 Redis 实例中的 Lua 函数 ctx: 上下文, libName: 库名称, funcName: 函数名称, numKeys: 键数量, options: 调用选项

func (*Client) TFunctionDelete added in v3.6.12

func (r *Client) TFunctionDelete(ctx context.Context, libName string) (val string, err error)

TFunctionDelete 从 Redis 实例中删除 Lua 函数库 ctx: 上下文, libName: 要删除的库名称

func (*Client) TFunctionList added in v3.6.12

func (r *Client) TFunctionList(ctx context.Context) (val []map[string]any, err error)

TFunctionList 列出 Redis 实例中的所有 Lua 函数库 ctx: 上下文

func (*Client) TFunctionListArgs added in v3.6.12

func (r *Client) TFunctionListArgs(ctx context.Context, options *redis.TFunctionListOptions) (val []map[string]any, err error)

TFunctionListArgs 列出 Redis 实例中的所有 Lua 函数库 ctx: 上下文, options: 列表选项

func (*Client) TFunctionLoad added in v3.6.12

func (r *Client) TFunctionLoad(ctx context.Context, lib string) (val string, err error)

TFunctionLoad 将 Lua 函数库加载到 Redis 实例中 ctx: 上下文, lib: Lua库代码

func (*Client) TFunctionLoadArgs added in v3.6.12

func (r *Client) TFunctionLoadArgs(ctx context.Context, lib string, options *redis.TFunctionLoadOptions) (val string, err error)

TFunctionLoadArgs 将 Lua 函数库加载到 Redis 实例中 ctx: 上下文, lib: Lua库代码, options: 加载选项

func (*Client) TSAdd added in v3.6.12

func (r *Client) TSAdd(ctx context.Context, key string, timestamp any, value float64) (val int64, err error)

TSAdd 向时间序列中添加数据点 ctx: 上下文, key: 时间序列键名, timestamp: 时间戳, value: 数据值

func (*Client) TSAddWithArgs added in v3.6.12

func (r *Client) TSAddWithArgs(ctx context.Context, key string, timestamp any, value float64, options *redis.TSOptions) (val int64, err error)

TSAddWithArgs 向时间序列中添加数据点(带选项) ctx: 上下文, key: 时间序列键名, timestamp: 时间戳, value: 数据值, options: 时间序列选项

func (*Client) TSAlter added in v3.6.12

func (r *Client) TSAlter(ctx context.Context, key string, options *redis.TSAlterOptions) (val string, err error)

TSAlter 修改时间序列属性 ctx: 上下文, key: 时间序列键名, options: 修改选项

func (*Client) TSCreate added in v3.6.12

func (r *Client) TSCreate(ctx context.Context, key string) (val string, err error)

TSCreate 创建新的时间序列 ctx: 上下文, key: 时间序列键名

func (*Client) TSCreateRule added in v3.6.12

func (r *Client) TSCreateRule(ctx context.Context, sourceKey string, destKey string, aggregator redis.Aggregator, bucketDuration int) (val string, err error)

TSCreateRule 创建时间序列聚合规则 ctx: 上下文, sourceKey: 源时间序列键名, destKey: 目标时间序列键名, aggregator: 聚合器类型, bucketDuration: 时间桶大小

func (*Client) TSCreateRuleWithArgs added in v3.6.12

func (r *Client) TSCreateRuleWithArgs(ctx context.Context, sourceKey string, destKey string, aggregator redis.Aggregator, bucketDuration int, options *redis.TSCreateRuleOptions) (val string, err error)

TSCreateRuleWithArgs 创建时间序列聚合规则(带选项) ctx: 上下文, sourceKey: 源时间序列键名, destKey: 目标时间序列键名, aggregator: 聚合器类型, bucketDuration: 时间桶大小, options: 创建规则选项

func (*Client) TSCreateWithArgs added in v3.6.12

func (r *Client) TSCreateWithArgs(ctx context.Context, key string, options *redis.TSOptions) (val string, err error)

TSCreateWithArgs 创建新的时间序列(带选项) ctx: 上下文, key: 时间序列键名, options: 时间序列选项

func (*Client) TSDecrBy added in v3.6.12

func (r *Client) TSDecrBy(ctx context.Context, key string, timestamp float64) (val int64, err error)

TSDecrBy 减少时间序列值 ctx: 上下文, key: 时间序列键名, timestamp: 时间戳

func (*Client) TSDecrByWithArgs added in v3.6.12

func (r *Client) TSDecrByWithArgs(ctx context.Context, key string, timestamp float64, options *redis.TSIncrDecrOptions) (val int64, err error)

TSDecrByWithArgs 减少时间序列值(带选项) ctx: 上下文, key: 时间序列键名, timestamp: 时间戳, options: 增减选项

func (*Client) TSDel added in v3.6.12

func (r *Client) TSDel(ctx context.Context, key string, fromTimestamp int, toTimestamp int) (val int64, err error)

TSDel 删除时间序列数据点 ctx: 上下文, key: 时间序列键名, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳

func (*Client) TSDeleteRule added in v3.6.12

func (r *Client) TSDeleteRule(ctx context.Context, sourceKey string, destKey string) (val string, err error)

TSDeleteRule 删除时间序列聚合规则 ctx: 上下文, sourceKey: 源时间序列键名, destKey: 目标时间序列键名

func (*Client) TSGet added in v3.6.12

func (r *Client) TSGet(ctx context.Context, key string) (val redis.TSTimestampValue, err error)

TSGet 获取时间序列最新数据点 ctx: 上下文, key: 时间序列键名

func (*Client) TSGetWithArgs added in v3.6.12

func (r *Client) TSGetWithArgs(ctx context.Context, key string, options *redis.TSGetOptions) (val redis.TSTimestampValue, err error)

TSGetWithArgs 获取时间序列最新数据点(带选项) ctx: 上下文, key: 时间序列键名, options: 获取选项

func (*Client) TSIncrBy added in v3.6.12

func (r *Client) TSIncrBy(ctx context.Context, key string, timestamp float64) (val int64, err error)

TSIncrBy 增加时间序列值 ctx: 上下文, key: 时间序列键名, timestamp: 时间戳

func (*Client) TSIncrByWithArgs added in v3.6.12

func (r *Client) TSIncrByWithArgs(ctx context.Context, key string, timestamp float64, options *redis.TSIncrDecrOptions) (val int64, err error)

TSIncrByWithArgs 增加时间序列值(带选项) ctx: 上下文, key: 时间序列键名, timestamp: 时间戳, options: 增减选项

func (*Client) TSInfo added in v3.6.12

func (r *Client) TSInfo(ctx context.Context, key string) (val map[string]any, err error)

TSInfo 获取时间序列信息 ctx: 上下文, key: 时间序列键名

func (*Client) TSInfoWithArgs added in v3.6.12

func (r *Client) TSInfoWithArgs(ctx context.Context, key string, options *redis.TSInfoOptions) (val map[string]any, err error)

TSInfoWithArgs 获取时间序列信息(带选项) ctx: 上下文, key: 时间序列键名, options: 信息获取选项

func (*Client) TSMAdd added in v3.6.12

func (r *Client) TSMAdd(ctx context.Context, ktvSlices [][]any) (val []int64, err error)

TSMAdd 批量添加时间序列数据点 ctx: 上下文, ktvSlices: 键-时间戳-值切片数组

func (*Client) TSMGet added in v3.6.12

func (r *Client) TSMGet(ctx context.Context, filters []string) (val map[string][]any, err error)

TSMGet 批量获取时间序列最新数据点 ctx: 上下文, filters: 过滤表达式数组

func (*Client) TSMGetWithArgs added in v3.6.12

func (r *Client) TSMGetWithArgs(ctx context.Context, filters []string, options *redis.TSMGetOptions) (val map[string][]any, err error)

TSMGetWithArgs 批量获取时间序列最新数据点(带选项) ctx: 上下文, filters: 过滤表达式数组, options: 获取选项

func (*Client) TSMRange added in v3.6.12

func (r *Client) TSMRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) (val map[string][]any, err error)

TSMRange 批量查询时间序列数据点 ctx: 上下文, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳, filterExpr: 过滤表达式数组

func (*Client) TSMRangeWithArgs added in v3.6.12

func (r *Client) TSMRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *redis.TSMRangeOptions) (val map[string][]any, err error)

TSMRangeWithArgs 批量查询时间序列数据点(带选项) ctx: 上下文, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳, filterExpr: 过滤表达式数组, options: 查询选项

func (*Client) TSMRevRange added in v3.6.12

func (r *Client) TSMRevRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) (val map[string][]any, err error)

TSMRevRange 批量反向查询时间序列数据点 ctx: 上下文, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳, filterExpr: 过滤表达式数组

func (*Client) TSMRevRangeWithArgs added in v3.6.12

func (r *Client) TSMRevRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *redis.TSMRevRangeOptions) (val map[string][]any, err error)

TSMRevRangeWithArgs 批量反向查询时间序列数据点(带选项) ctx: 上下文, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳, filterExpr: 过滤表达式数组, options: 查询选项

func (*Client) TSQueryIndex added in v3.6.12

func (r *Client) TSQueryIndex(ctx context.Context, filterExpr []string) (val []string, err error)

TSQueryIndex 查询匹配过滤器的时间序列键名 ctx: 上下文, filterExpr: 过滤表达式数组

func (*Client) TSRange added in v3.6.12

func (r *Client) TSRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) (val []redis.TSTimestampValue, err error)

TSRange 查询时间序列数据点 ctx: 上下文, key: 时间序列键名, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳

func (*Client) TSRangeWithArgs added in v3.6.12

func (r *Client) TSRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *redis.TSRangeOptions) (val []redis.TSTimestampValue, err error)

TSRangeWithArgs 查询时间序列数据点(带选项) ctx: 上下文, key: 时间序列键名, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳, options: 查询选项

func (*Client) TSRevRange added in v3.6.12

func (r *Client) TSRevRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) (val []redis.TSTimestampValue, err error)

TSRevRange 反向查询时间序列数据点 ctx: 上下文, key: 时间序列键名, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳

func (*Client) TSRevRangeWithArgs added in v3.6.12

func (r *Client) TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *redis.TSRevRangeOptions) (val []redis.TSTimestampValue, err error)

TSRevRangeWithArgs 反向查询时间序列数据点(带选项) ctx: 上下文, key: 时间序列键名, fromTimestamp: 起始时间戳, toTimestamp: 结束时间戳, options: 查询选项

func (*Client) TTL

func (r *Client) TTL(ctx context.Context, key string) (val time.Duration, err error)

TTL 返回key的剩余生存时间 key: 要查询的key

func (*Client) Time

func (r *Client) Time(ctx context.Context) (val time.Time, err error)

Time 获取服务器时间 ctx: 上下文

func (*Client) TopKAdd added in v3.8.19

func (r *Client) TopKAdd(ctx context.Context, key string, elements ...any) (val []string, err error)

TopKAdd 添加元素到TopK ctx: 上下文, key: TopK键名, elements: 要添加的元素

func (*Client) TopKCount added in v3.8.19

func (r *Client) TopKCount(ctx context.Context, key string, elements ...any) (val []int64, err error)

TopKCount 获取TopK的元素数量 ctx: 上下文, key: TopK键名, elements: 要计数的元素

func (*Client) TopKIncrBy added in v3.8.19

func (r *Client) TopKIncrBy(ctx context.Context, key string, elements ...any) (val []string, err error)

TopKIncrBy 增加元素到TopK ctx: 上下文, key: TopK键名, elements: 要增加的元素

func (*Client) TopKInfo added in v3.8.19

func (r *Client) TopKInfo(ctx context.Context, key string) (val redis.TopKInfo, err error)

TopKInfo 获取TopK的信息 ctx: 上下文, key: TopK键名

func (*Client) TopKList added in v3.8.19

func (r *Client) TopKList(ctx context.Context, key string) (val []string, err error)

TopKList 获取TopK的列表 ctx: 上下文, key: TopK键名

func (*Client) TopKListWithCount added in v3.8.19

func (r *Client) TopKListWithCount(ctx context.Context, key string) (val map[string]int64, err error)

TopKListWithCount 获取TopK的列表 ctx: 上下文, key: TopK键名

func (*Client) TopKQuery added in v3.8.19

func (r *Client) TopKQuery(ctx context.Context, key string, elements ...any) (val []bool, err error)

TopKQuery 查询TopK ctx: 上下文, key: TopK键名, elements: 要查询的元素

func (*Client) TopKReserve added in v3.8.19

func (r *Client) TopKReserve(ctx context.Context, key string, k int64) (val string, err error)

TopKReserve 创建TopK ctx: 上下文, key: TopK键名, k: 保留元素数量

func (*Client) TopKReserveWithOptions added in v3.8.19

func (r *Client) TopKReserveWithOptions(ctx context.Context, key string, k, width, depth int64, decay float64) (val string, err error)

TopKReserveWithOptions 创建TopK ctx: 上下文, key: TopK键名, k: 保留元素数量, width: 宽度, depth: 深度, decay: 衰减因子

func (*Client) Touch

func (r *Client) Touch(ctx context.Context, keys ...string) (val int64, err error)

Touch 更改key的最后访问时间 keys: 要操作的key列表

func (*Client) TxPipeline

func (r *Client) TxPipeline() (val redis.Pipeliner, err error)

TxPipeline 获取事务管道 无参数

func (*Client) TxPipelined

func (r *Client) TxPipelined(ctx context.Context, fn func(redis.Pipeliner) error) (val []redis.Cmder, err error)

TxPipelined 执行事务管道操作 ctx: 上下文, fn: 管道操作函数

func (*Client) Type

func (r *Client) Type(ctx context.Context, key string) (val string, err error)

Type 返回key存储值的类型 key: 要查询的key

func (r *Client) Unlink(ctx context.Context, keys ...string) (val int64, err error)

Unlink 异步删除键 ctx: 上下文, keys: 要删除的键列表

func (*Client) XAck

func (r *Client) XAck(ctx context.Context, stream string, group string, ids ...string) (val int64, err error)

XAck 确认消息已被处理 ctx: 上下文 stream: 流名称 group: 消费者组名称 ids: 消息ID列表

func (*Client) XAdd

func (r *Client) XAdd(ctx context.Context, a *redis.XAddArgs) (val string, err error)

XAdd 将指定的流条目追加到指定key的流中 ctx: 上下文 a: 流条目参数

func (*Client) XAutoClaim added in v3.2.31

func (r *Client) XAutoClaim(ctx context.Context, a *redis.XAutoClaimArgs) (val []redis.XMessage, start string, err error)

XAutoClaim 自动认领待处理消息 ctx: 上下文 a: 自动认领参数

func (*Client) XAutoClaimJustID added in v3.2.31

func (r *Client) XAutoClaimJustID(ctx context.Context, a *redis.XAutoClaimArgs) (val []string, start string, err error)

XAutoClaimJustID 自动认领待处理消息并仅返回ID ctx: 上下文 a: 自动认领参数

func (*Client) XClaim

func (r *Client) XClaim(ctx context.Context, a *redis.XClaimArgs) (val []redis.XMessage, err error)

XClaim 认领待处理消息 ctx: 上下文 a: 认领参数

func (*Client) XClaimJustID

func (r *Client) XClaimJustID(ctx context.Context, a *redis.XClaimArgs) (val []string, err error)

XClaimJustID 认领待处理消息并仅返回ID ctx: 上下文 a: 认领参数

func (*Client) XDel

func (r *Client) XDel(ctx context.Context, stream string, ids ...string) (val int64, err error)

XDel 从指定流中移除指定的条目 ctx: 上下文 stream: 流名称 ids: 要删除的条目ID列表

func (*Client) XGroupCreate

func (r *Client) XGroupCreate(ctx context.Context, stream string, group, start string) (val string, err error)

XGroupCreate 创建消费者组 ctx: 上下文 stream: 流名称 group: 消费者组名称 start: 起始ID

func (*Client) XGroupCreateConsumer added in v3.8.19

func (r *Client) XGroupCreateConsumer(ctx context.Context, stream string, group, consumer string) (val int64, err error)

XGroupCreateConsumer 创建消费者 ctx: 上下文 stream: 流名称 group: 消费者组名称 consumer: 消费者名称

func (*Client) XGroupCreateMkStream

func (r *Client) XGroupCreateMkStream(ctx context.Context, stream string, group, start string) (val string, err error)

XGroupCreateMkStream 创建消费者组并创建流(如果不存在) ctx: 上下文 stream: 流名称 group: 消费者组名称 start: 起始ID

func (*Client) XGroupDelConsumer

func (r *Client) XGroupDelConsumer(ctx context.Context, stream string, group, consumer string) (val int64, err error)

XGroupDelConsumer 删除消费者 ctx: 上下文 stream: 流名称 group: 消费者组名称 consumer: 消费者名称

func (*Client) XGroupDestroy

func (r *Client) XGroupDestroy(ctx context.Context, stream string, group string) (val int64, err error)

XGroupDestroy 删除消费者组 ctx: 上下文 stream: 流名称 group: 消费者组名称

func (*Client) XGroupSetID

func (r *Client) XGroupSetID(ctx context.Context, stream string, group, start string) (val string, err error)

XGroupSetID 设置消费者组的最后递送ID ctx: 上下文 stream: 流名称 group: 消费者组名称 start: 新的起始ID

func (*Client) XInfoConsumers added in v3.2.31

func (r *Client) XInfoConsumers(ctx context.Context, key string, group string) (val []redis.XInfoConsumer, err error)

XInfoConsumers 获取消费者信息 ctx: 上下文 key: 流名称 group: 消费者组名称

func (*Client) XInfoGroups

func (r *Client) XInfoGroups(ctx context.Context, key string) (val []redis.XInfoGroup, err error)

XInfoGroups 获取流消费者组信息 ctx: 上下文 key: 流名称

func (*Client) XInfoStream added in v3.2.31

func (r *Client) XInfoStream(ctx context.Context, key string) (val *redis.XInfoStream, err error)

XInfoStream 获取流信息 ctx: 上下文 key: 流名称

func (*Client) XInfoStreamFull added in v3.2.31

func (r *Client) XInfoStreamFull(ctx context.Context, key string, count int) (val *redis.XInfoStreamFull, err error)

XInfoStreamFull 获取流的完整信息 ctx: 上下文 key: 流名称 count: 返回条目数量

func (*Client) XLen

func (r *Client) XLen(ctx context.Context, stream string) (val int64, err error)

XLen 返回流中的条目数 ctx: 上下文 stream: 流名称

func (*Client) XPending

func (r *Client) XPending(ctx context.Context, stream string, group string) (val *redis.XPending, err error)

XPending 获取待处理消息信息 ctx: 上下文 stream: 流名称 group: 消费者组名称

func (*Client) XPendingExt

func (r *Client) XPendingExt(ctx context.Context, a *redis.XPendingExtArgs) (val []redis.XPendingExt, err error)

XPendingExt 获取待处理消息的详细信息 ctx: 上下文 a: 查询参数

func (*Client) XRange

func (r *Client) XRange(ctx context.Context, stream string, start, stop string) (val []redis.XMessage, err error)

XRange 返回流中满足给定ID范围的条目 ctx: 上下文 stream: 流名称 start: 起始ID stop: 结束ID

func (*Client) XRangeN

func (r *Client) XRangeN(ctx context.Context, stream string, start, stop string, count int64) (val []redis.XMessage, err error)

XRangeN 返回流中满足给定ID范围的条目,限制返回数量 ctx: 上下文 stream: 流名称 start: 起始ID stop: 结束ID count: 最大返回数量

func (*Client) XRead

func (r *Client) XRead(ctx context.Context, a *redis.XReadArgs) (val []redis.XStream, err error)

XRead 从一个或多个流中读取数据 ctx: 上下文 a: 读取参数

func (*Client) XReadGroup

func (r *Client) XReadGroup(ctx context.Context, a *redis.XReadGroupArgs) (val []redis.XStream, err error)

XReadGroup 从消费者组读取数据 ctx: 上下文 a: 读取参数

func (*Client) XReadStreams

func (r *Client) XReadStreams(ctx context.Context, streams ...string) (val []redis.XStream, err error)

XReadStreams 从多个流中读取数据 ctx: 上下文 streams: 流名称列表

func (*Client) XRevRange

func (r *Client) XRevRange(ctx context.Context, stream string, start, stop string) (val []redis.XMessage, err error)

XRevRange 以相反顺序返回流中满足给定ID范围的条目 ctx: 上下文 stream: 流名称 start: 起始ID stop: 结束ID

func (*Client) XRevRangeN

func (r *Client) XRevRangeN(ctx context.Context, stream string, start, stop string, count int64) (val []redis.XMessage, err error)

XRevRangeN 以相反顺序返回流中满足给定ID范围的条目,限制返回数量 ctx: 上下文 stream: 流名称 start: 起始ID stop: 结束ID count: 最大返回数量

func (*Client) XTrimMaxLen added in v3.2.31

func (r *Client) XTrimMaxLen(ctx context.Context, key string, maxLen int64) (val int64, err error)

XTrimMaxLen 根据最大长度修剪流 ctx: 上下文 key: 流名称 maxLen: 最大长度

func (*Client) XTrimMaxLenApprox added in v3.2.31

func (r *Client) XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) (val int64, err error)

XTrimMaxLenApprox 根据最大长度近似修剪流 ctx: 上下文 key: 流名称 maxLen: 最大长度 limit: 修剪限制

func (*Client) XTrimMinID added in v3.2.31

func (r *Client) XTrimMinID(ctx context.Context, key string, minID string) (val int64, err error)

XTrimMinID 根据最小ID修剪流 ctx: 上下文 key: 流名称 minID: 最小ID

func (*Client) XTrimMinIDApprox added in v3.2.31

func (r *Client) XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) (val int64, err error)

XTrimMinIDApprox 根据最小ID近似修剪流 ctx: 上下文 key: 流名称 minID: 最小ID limit: 修剪限制

func (*Client) ZAdd

func (r *Client) ZAdd(ctx context.Context, key string, members ...redis.Z) (val int64, err error)

ZAdd 向有序集合添加元素 ctx: 上下文 key: 有序集合键 members: 要添加的元素及其分数

func (*Client) ZAddArgs added in v3.2.31

func (r *Client) ZAddArgs(ctx context.Context, key string, args redis.ZAddArgs) (val int64, err error)

ZAddArgs 使用ZAddArgs参数向有序集合添加元素 ctx: 上下文 key: 有序集合键 args: ZAdd参数

func (*Client) ZAddArgsIncr added in v3.2.31

func (r *Client) ZAddArgsIncr(ctx context.Context, key string, args redis.ZAddArgs) (val float64, err error)

ZAddArgsIncr 使用ZAddArgs参数增加元素的分数 ctx: 上下文 key: 有序集合键 args: ZAdd参数

func (*Client) ZAddGT added in v3.6.12

func (r *Client) ZAddGT(ctx context.Context, key string, members ...redis.Z) (val int64, err error)

ZAddGT 仅当新分数大于当前分数时更新元素 ctx: 上下文 key: 有序集合键 members: 要添加的元素及其分数

func (*Client) ZAddLT added in v3.6.12

func (r *Client) ZAddLT(ctx context.Context, key string, members ...redis.Z) (val int64, err error)

ZAddLT 仅当新分数小于当前分数时更新元素 ctx: 上下文 key: 有序集合键 members: 要添加的元素及其分数

func (*Client) ZAddNX

func (r *Client) ZAddNX(ctx context.Context, key string, members ...redis.Z) (val int64, err error)

ZAddNX 仅当元素不存在时添加元素 ctx: 上下文 key: 有序集合键 members: 要添加的元素及其分数

func (*Client) ZAddXX

func (r *Client) ZAddXX(ctx context.Context, key string, members ...redis.Z) (val int64, err error)

ZAddXX 仅当元素存在时更新元素 ctx: 上下文 key: 有序集合键 members: 要添加的元素及其分数

func (*Client) ZCard

func (r *Client) ZCard(ctx context.Context, key string) (val int64, err error)

ZCard 获取有序集合的元素数量 ctx: 上下文 key: 有序集合键

func (*Client) ZCount

func (r *Client) ZCount(ctx context.Context, key string, min, max string) (val int64, err error)

ZCount 统计分数在指定范围内的元素数量 ctx: 上下文 key: 有序集合键 min: 最小分数 max: 最大分数

func (*Client) ZDiff added in v3.2.31

func (r *Client) ZDiff(ctx context.Context, keys ...string) (val []string, err error)

ZDiff 计算多个有序集合的差集 ctx: 上下文 keys: 一个或多个有序集合键

func (*Client) ZDiffStore added in v3.2.31

func (r *Client) ZDiffStore(ctx context.Context, destination string, keys ...string) (val int64, err error)

ZDiffStore 计算多个有序集合的差集并存储结果 ctx: 上下文 destination: 目标集合键 keys: 一个或多个有序集合键

func (*Client) ZDiffWithScores added in v3.2.31

func (r *Client) ZDiffWithScores(ctx context.Context, keys ...string) (val []redis.Z, err error)

ZDiffWithScores 计算多个有序集合的差集并返回分数 ctx: 上下文 keys: 一个或多个有序集合键

func (*Client) ZIncrBy

func (r *Client) ZIncrBy(ctx context.Context, key string, increment float64, member string) (val float64, err error)

ZIncrBy 增加有序集合中元素的分数 ctx: 上下文 key: 有序集合键 increment: 增量 member: 元素

func (*Client) ZInter added in v3.2.31

func (r *Client) ZInter(ctx context.Context, store *redis.ZStore) (val []string, err error)

ZInter 计算多个有序集合的交集 ctx: 上下文 store: ZStore参数

func (*Client) ZInterCard added in v3.2.31

func (r *Client) ZInterCard(ctx context.Context, limit int64, keys ...string) (val int64, err error)

ZInterCard 计算多个有序集合的交集基数 ctx: 上下文 limit: 最大返回数量 keys: 一个或多个有序集合键

func (*Client) ZInterStore

func (r *Client) ZInterStore(ctx context.Context, key string, store *redis.ZStore) (val int64, err error)

ZInterStore 计算多个有序集合的交集并存储结果 ctx: 上下文 key: 目标有序集合键 store: ZStore参数

func (*Client) ZInterWithScores added in v3.2.31

func (r *Client) ZInterWithScores(ctx context.Context, store *redis.ZStore) (val []redis.Z, err error)

ZInterWithScores 计算多个有序集合的交集并返回分数 ctx: 上下文 store: ZStore参数

func (*Client) ZLexCount

func (r *Client) ZLexCount(ctx context.Context, key string, min, max string) (val int64, err error)

ZLexCount 统计字典序在指定范围内的元素数量 ctx: 上下文 key: 有序集合键 min: 最小字典序 max: 最大字典序

func (*Client) ZMPop added in v3.5.4

func (r *Client) ZMPop(ctx context.Context, order string, count int64, keys ...string) (key string, ret []redis.Z, err error)

ZMPop 从有序集合中弹出元素 ctx: 上下文 order: 排序方式 count: 弹出数量 keys: 一个或多个有序集合键

func (*Client) ZMScore added in v3.2.31

func (r *Client) ZMScore(ctx context.Context, key string, members ...string) (val []float64, err error)

ZMScore 获取多个元素的分数 ctx: 上下文 key: 有序集合键 members: 要查询的元素

func (*Client) ZPopMax

func (r *Client) ZPopMax(ctx context.Context, key string, count ...int64) (val []redis.Z, err error)

ZPopMax 删除并返回分数最高的元素 ctx: 上下文 key: 有序集合键 count: 要删除的元素数量

func (*Client) ZPopMin

func (r *Client) ZPopMin(ctx context.Context, key string, count ...int64) (val []redis.Z, err error)

ZPopMin 删除并返回分数最低的元素 ctx: 上下文 key: 有序集合键 count: 要删除的元素数量

func (*Client) ZRandMember added in v3.2.31

func (r *Client) ZRandMember(ctx context.Context, key string, count int) (val []string, err error)

ZRandMember 随机获取有序集合中的元素 ctx: 上下文 key: 有序集合键 count: 要获取的元素数量

func (*Client) ZRandMemberWithScores added in v3.2.31

func (r *Client) ZRandMemberWithScores(ctx context.Context, key string, count int) (val []redis.Z, err error)

ZRandMemberWithScores 随机获取有序集合中的元素及其分数 ctx: 上下文 key: 有序集合键 count: 要获取的元素数量

func (*Client) ZRange

func (r *Client) ZRange(ctx context.Context, key string, start, stop int64) (val []string, err error)

ZRange 获取有序集合指定范围内的元素 ctx: 上下文 key: 有序集合键 start: 起始索引 stop: 结束索引

func (*Client) ZRangeArgs added in v3.2.31

func (r *Client) ZRangeArgs(ctx context.Context, z redis.ZRangeArgs) (val []string, err error)

ZRangeArgs 使用ZRangeArgs参数获取有序集合元素 ctx: 上下文 z: ZRangeArgs参数

func (*Client) ZRangeArgsWithScores added in v3.2.31

func (r *Client) ZRangeArgsWithScores(ctx context.Context, z redis.ZRangeArgs) (val []redis.Z, err error)

ZRangeArgsWithScores 使用ZRangeArgs参数获取有序集合元素及其分数 ctx: 上下文 z: ZRangeArgs参数

func (*Client) ZRangeByLex

func (r *Client) ZRangeByLex(ctx context.Context, key string, opt *redis.ZRangeBy) (val []string, err error)

ZRangeByLex 获取字典序在指定范围内的元素 ctx: 上下文 key: 有序集合键 opt: ZRangeBy参数

func (*Client) ZRangeByScore

func (r *Client) ZRangeByScore(ctx context.Context, key string, opt *redis.ZRangeBy) (val []string, err error)

ZRangeByScore 获取分数在指定范围内的元素 ctx: 上下文 key: 有序集合键 opt: ZRangeBy参数

func (*Client) ZRangeByScoreWithScores

func (r *Client) ZRangeByScoreWithScores(ctx context.Context, key string, opt *redis.ZRangeBy) (val []redis.Z, err error)

ZRangeByScoreWithScores 获取分数在指定范围内的元素及其分数 ctx: 上下文 key: 有序集合键 opt: ZRangeBy参数

func (*Client) ZRangeStore added in v3.2.31

func (r *Client) ZRangeStore(ctx context.Context, dst string, z redis.ZRangeArgs) (val int64, err error)

ZRangeStore 使用ZRangeArgs参数获取有序集合元素并存储到目标集合 ctx: 上下文 dst: 目标集合键 z: ZRangeArgs参数

func (*Client) ZRangeWithScores

func (r *Client) ZRangeWithScores(ctx context.Context, key string, start, stop int64) (val []redis.Z, err error)

ZRangeWithScores 获取有序集合指定范围内的元素及其分数 ctx: 上下文 key: 有序集合键 start: 起始索引 stop: 结束索引

func (*Client) ZRank

func (r *Client) ZRank(ctx context.Context, key string, member string) (val int64, err error)

ZRank 获取元素的排名 ctx: 上下文 key: 有序集合键 member: 元素

func (*Client) ZRankWithScore added in v3.6.1

func (r *Client) ZRankWithScore(ctx context.Context, key string, member string) (val redis.RankScore, err error)

ZRankWithScore 获取元素的排名及其分数 ctx: 上下文 key: 有序集合键 member: 元素

func (*Client) ZRem

func (r *Client) ZRem(ctx context.Context, key string, members ...any) (val int64, err error)

ZRem 移除有序集合中的元素 ctx: 上下文 key: 有序集合键 members: 要移除的元素

func (*Client) ZRemRangeByLex

func (r *Client) ZRemRangeByLex(ctx context.Context, key string, min, max string) (val int64, err error)

ZRemRangeByLex 移除指定字典序范围内的元素 ctx: 上下文 key: 有序集合键 min: 最小字典序 max: 最大字典序

func (*Client) ZRemRangeByRank

func (r *Client) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) (val int64, err error)

ZRemRangeByRank 移除指定排名范围内的元素 ctx: 上下文 key: 有序集合键 start: 起始排名 stop: 结束排名

func (*Client) ZRemRangeByScore

func (r *Client) ZRemRangeByScore(ctx context.Context, key string, min, max string) (val int64, err error)

ZRemRangeByScore 移除指定分数范围内的元素 ctx: 上下文 key: 有序集合键 min: 最小分数 max: 最大分数

func (*Client) ZRevRange

func (r *Client) ZRevRange(ctx context.Context, key string, start, stop int64) (val []string, err error)

ZRevRange 获取指定范围内的元素(倒序) ctx: 上下文 key: 有序集合键 start: 起始索引 stop: 结束索引

func (*Client) ZRevRangeByLex

func (r *Client) ZRevRangeByLex(ctx context.Context, key string, opt *redis.ZRangeBy) (val []string, err error)

ZRevRangeByLex 获取指定字典序范围内的元素(倒序) ctx: 上下文 key: 有序集合键 opt: ZRangeBy参数

func (*Client) ZRevRangeByScore

func (r *Client) ZRevRangeByScore(ctx context.Context, key string, opt *redis.ZRangeBy) (val []string, err error)

ZRevRangeByScore 获取指定分数范围内的元素(倒序) ctx: 上下文 key: 有序集合键 opt: ZRangeBy参数

func (*Client) ZRevRangeByScoreWithScores

func (r *Client) ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *redis.ZRangeBy) (val []redis.Z, err error)

ZRevRangeByScoreWithScores 获取指定分数范围内的元素及其分数(倒序) ctx: 上下文 key: 有序集合键 opt: ZRangeBy参数

func (*Client) ZRevRangeWithScores

func (r *Client) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) (val []redis.Z, err error)

ZRevRangeWithScores 获取指定范围内的元素及其分数(倒序) ctx: 上下文 key: 有序集合键 start: 起始索引 stop: 结束索引

func (*Client) ZRevRank

func (r *Client) ZRevRank(ctx context.Context, key string, member string) (val int64, err error)

ZRevRank 获取元素的倒序排名 ctx: 上下文 key: 有序集合键 member: 元素

func (*Client) ZRevRankWithScore added in v3.6.1

func (r *Client) ZRevRankWithScore(ctx context.Context, key string, member string) (val redis.RankScore, err error)

ZRevRankWithScore 获取元素的倒序排名及其分数 ctx: 上下文 key: 有序集合键 member: 元素

func (*Client) ZScan

func (r *Client) ZScan(ctx context.Context, key string, cursorIn uint64, match string, count int64) (val []string, cursor uint64, err error)

ZScan 扫描有序集合中的元素 ctx: 上下文 key: 有序集合键 cursorIn: 游标 match: 匹配模式 count: 返回数量

func (*Client) ZScore

func (r *Client) ZScore(ctx context.Context, key string, member string) (val float64, err error)

ZScore 获取元素的分数 ctx: 上下文 key: 有序集合键 member: 元素

func (*Client) ZUnion added in v3.2.31

func (r *Client) ZUnion(ctx context.Context, store redis.ZStore) (val []string, err error)

ZUnion 计算多个有序集合的并集 ctx: 上下文 store: ZStore参数

func (*Client) ZUnionStore

func (r *Client) ZUnionStore(ctx context.Context, dest string, store *redis.ZStore) (val int64, err error)

ZUnionStore 计算多个有序集合的并集并存储结果 ctx: 上下文 dest: 目标集合键 store: ZStore参数

func (*Client) ZUnionWithScores added in v3.2.31

func (r *Client) ZUnionWithScores(ctx context.Context, store redis.ZStore) (val []redis.Z, err error)

ZUnionWithScores 计算多个有序集合的并集并返回分数 ctx: 上下文 store: ZStore参数

type MetricsHook added in v3.8.21

type MetricsHook struct {
	redis.Hook
}

func (MetricsHook) DialHook added in v3.8.21

func (op MetricsHook) DialHook(hook redis.DialHook) redis.DialHook

func (MetricsHook) ProcessHook added in v3.8.21

func (op MetricsHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook

func (MetricsHook) ProcessPipelineHook added in v3.8.21

func (op MetricsHook) ProcessPipelineHook(hook redis.ProcessPipelineHook) redis.ProcessPipelineHook

type OpenTraceHook

type OpenTraceHook struct {
	redis.Hook
}

OpenTraceHook ...

func (OpenTraceHook) DialHook added in v3.2.33

func (op OpenTraceHook) DialHook(hook redis.DialHook) redis.DialHook

DialHook 返回redis连接hook hook: 原始redis连接hook

func (OpenTraceHook) ProcessHook added in v3.2.33

func (op OpenTraceHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook

ProcessHook 返回redis命令处理hook hook: 原始redis命令处理hook

func (OpenTraceHook) ProcessPipelineHook added in v3.2.34

func (op OpenTraceHook) ProcessPipelineHook(hook redis.ProcessPipelineHook) redis.ProcessPipelineHook

ProcessPipelineHook 返回redis管道命令处理hook hook: 原始redis管道命令处理hook

type Option added in v3.4.2

type Option func(r *Client)

func WithAddr added in v3.4.2

func WithAddr(Addr string) Option

WithAddr 设置单节点地址 Addr: 单节点地址

func WithAddrs added in v3.4.2

func WithAddrs(Addrs map[string]string) Option

WithAddrs 设置分片地址 Addrs: 分片地址映射

func WithClientType added in v3.4.3

func WithClientType(ClientType string) Option

WithClientType 设置Redis客户端类型 ClientType: 客户端类型(normal,cluster,failover,ring)

func WithDatabase added in v3.4.2

func WithDatabase(Database int) Option

WithDatabase 设置Redis数据库 Database: 数据库编号

func WithEnableMetric added in v3.8.21

func WithEnableMetric(EnableMetric bool) Option

WithEnableMetric 禁用指标采集 EnableMetric: 是否禁用指标采集

func WithEnableTrace added in v3.8.21

func WithEnableTrace(EnableTrace bool) Option

WithEnableTrace 禁用链路追踪 EnableTrace: 是否禁用链路追踪

func WithHosts added in v3.4.2

func WithHosts(Hosts []string) Option

WithHosts 设置Redis主机地址 Hosts: 主机地址列表

func WithMasterName added in v3.4.2

func WithMasterName(MasterName string) Option

WithMasterName 设置哨兵主节点名称 MasterName: 主节点名称

func WithPassword added in v3.4.2

func WithPassword(Password string) Option

WithPassword 设置Redis密码 Password: 认证密码

func WithPoolSize added in v3.4.2

func WithPoolSize(PoolSize int) Option

WithPoolSize 设置连接池大小 PoolSize: 连接池大小

type RWType

type RWType string

RWType Client Reader and Writer

const (
	// OnlyRead serves as a search suffix for configuration parameters
	OnlyRead RWType = "READER"
	// OnlyWrite serves as a search suffix for configuration parameters
	OnlyWrite RWType = "WRITER"
	// ReadAndWrite serves as a search suffix for configuration parameters
	ReadAndWrite RWType = ""
)

OnlyRead ...

func (*RWType) FmtSuffix

func (rw *RWType) FmtSuffix(key string) string

FmtSuffix get fmtstring of key+ "_" + suffix

func (*RWType) IsReadOnly

func (rw *RWType) IsReadOnly() bool

IsReadOnly will return Is it read-only

type RedisNode added in v3.4.2

type RedisNode interface {
	redis.UniversalClient
	redis.Cmdable
}

RedisNode interface represents a redis node.

Jump to

Keyboard shortcuts

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