redis

package
v3.8.13 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SearchInvalid = SearchAggregator(iota)
	SearchAvg
	SearchSum
	SearchMin
	SearchMax
	SearchCount
	SearchCountDistinct
	SearchCountDistinctish
	SearchStdDev
	SearchQuantile
	SearchToList
	SearchFirstValue
	SearchRandomSample
)
View Source
const (
	SearchFieldTypeInvalid = SearchFieldType(iota)
	SearchFieldTypeNumeric
	SearchFieldTypeTag
	SearchFieldTypeText
	SearchFieldTypeGeo
	SearchFieldTypeVector
	SearchFieldTypeGeoShape
)
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 ...

View Source
const RequestCmdStart = CmdStart("start")

RequestCmdStart ...

Variables

This section is empty.

Functions

func AppendArg

func AppendArg(b []byte, v any) []byte

AppendArg ...

func Caller added in v3.4.4

func Caller(skip int) map[string]string

func String

func String(b []byte) string

String ...

Types

type AggregateQuery added in v3.6.20

type AggregateQuery []any

func FTAggregateQuery added in v3.6.20

func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery

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 // 数据库
	// Automatically adds a prefix to all keys
	KeyPrefix string // 前缀标识
	// The maximum number of retries before giving up. Command is retried
	// on network errors and MOVED/ASK redirects.
	// Default is 16.
	// 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
	DisableMetric bool // 关闭指标采集
	DisableTrace  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)

func (*Client) ACLDryRun added in v3.5.4

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

func (*Client) ACLLog added in v3.6.4

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

func (*Client) ACLLogReset added in v3.6.4

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

func (*Client) Append

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

Append 如果 key 已经存在并且是一个字符串, APPEND 命令将 value 追加到 key 原来的值的末尾。 如果 key 不存在, APPEND 就简单地将给定 key 设为 value ,就像执行 SET key value 一样。

func (*Client) BLMPop added in v3.5.4

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

func (*Client) BLMove added in v3.2.31

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

func (*Client) BLPop

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

BLPop 是列表的阻塞式(blocking)弹出原语。 它是 LPop 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BLPop 命令阻塞,直到等待超时或发现可弹出元素为止。 当给定多个 key 参数时,按参数 key 的先后顺序依次检查各个列表,弹出第一个非空列表的头元素。

func (*Client) BRPop

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

BRPop 是列表的阻塞式(blocking)弹出原语。 它是 RPOP 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BRPOP 命令阻塞,直到等待超时或发现可弹出元素为止。 当给定多个 key 参数时,按参数 key 的先后顺序依次检查各个列表,弹出第一个非空列表的尾部元素。 关于阻塞操作的更多信息,请查看 BLPOP 命令, BRPOP 除了弹出元素的位置和 BLPOP 不同之外,其他表现一致。

func (*Client) BRPopLPush

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

BRPopLPush 是 RPOPLPUSH 的阻塞版本,当给定列表 source 不为空时, BRPOPLPUSH 的表现和 RPOPLPUSH 一样。 当列表 source 为空时, BRPOPLPUSH 命令将阻塞连接,直到等待超时,或有另一个客户端对 source 执行 LPUSH 或 RPUSH 命令为止。

func (*Client) BZMPop added in v3.5.4

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

func (*Client) BZPopMax

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

BZPopMax 是有序集合命令 ZPOPMAX带有阻塞功能的版本。

func (*Client) BZPopMin

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

BZPopMin 是有序集合命令 ZPOPMIN带有阻塞功能的版本。

func (*Client) BgRewriteAOF

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

BgRewriteAOF 异步重写附加文件

func (*Client) BgSave

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

BgSave 将数据集异步保存到磁盘

func (*Client) BitCount

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

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

func (*Client) BitField

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

BitField -> BitCount

func (*Client) BitOpAnd

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

BitOpAnd -> BitCount

func (*Client) BitOpNot

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

BitOpNot -> BitCount

func (*Client) BitOpOr

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

BitOpOr -> BitCount

func (*Client) BitOpXor

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

BitOpXor -> BitCount

func (*Client) BitPos

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

BitPos -> BitCount

func (*Client) BitPosSpan added in v3.6.12

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

func (*Client) ClientGetName

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

ClientGetName returns the name of the connection.

func (*Client) ClientID

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

ClientID Returns the client ID for the current connection

func (*Client) ClientInfo added in v3.6.1

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

func (*Client) ClientKill

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

ClientKill 杀掉客户端的连接

func (*Client) ClientKillByFilter

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

ClientKillByFilter is new style synx, while the ClientKill is old CLIENT KILL <option> [value] ... <option> [value]

func (*Client) ClientList

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

ClientList 获取客户端连接列表

func (*Client) ClientPause

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

ClientPause 停止处理来自客户端的命令一段时间

func (*Client) ClientUnblock added in v3.2.31

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

func (*Client) ClientUnblockWithError added in v3.2.31

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

func (*Client) ClientUnpause added in v3.2.31

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

ClientPause 停止处理来自客户端的命令一段时间

func (*Client) ClusterAddSlots

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

ClusterAddSlots Assign new hash slots to receiving node

func (*Client) ClusterAddSlotsRange

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

ClusterAddSlotsRange -> ClusterAddSlots

func (*Client) ClusterCountFailureReports

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

ClusterCountFailureReports Return the number of failure reports active for a given node

func (*Client) ClusterCountKeysInSlot

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

ClusterCountKeysInSlot Return the number of local keys in the specified hash slot

func (*Client) ClusterDelSlots

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

ClusterDelSlots Set hash slots as unbound in receiving node

func (*Client) ClusterDelSlotsRange

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

ClusterDelSlotsRange -> ClusterDelSlots

func (*Client) ClusterFailover

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

ClusterFailover Forces a replica to perform a manual failover of its master.

func (*Client) ClusterForget

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

ClusterForget Remove a node from the nodes table

func (*Client) ClusterGetKeysInSlot

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

ClusterGetKeysInSlot Return local key names in the specified hash slot

func (*Client) ClusterInfo

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

ClusterInfo Provides info about Redis Cluster node state

func (*Client) ClusterKeySlot

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

ClusterKeySlot Returns the hash slot of the specified key

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

func (*Client) ClusterMeet

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

ClusterMeet Force a node cluster to handshake with another node

func (*Client) ClusterMyShardID added in v3.6.1

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

func (*Client) ClusterNodes

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

ClusterNodes Get Cluster config for the node

func (*Client) ClusterReplicate

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

ClusterReplicate Reconfigure a node as a replica of the specified master node

func (*Client) ClusterResetHard

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

ClusterResetHard Reset a Redis Cluster node

func (*Client) ClusterResetSoft

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

ClusterResetSoft Reset a Redis Cluster node

func (*Client) ClusterSaveConfig

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

ClusterSaveConfig Forces the node to save cluster state on disk

func (*Client) ClusterShards added in v3.5.4

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

func (*Client) ClusterSlaves

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

ClusterSlaves List replica nodes of the specified master node

func (*Client) ClusterSlots

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

ClusterSlots 获取集群节点的映射数组

func (*Client) Command

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

Command 返回有关所有Redis命令的详细信息的Array回复

func (*Client) CommandGetKeys added in v3.5.4

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

func (*Client) CommandGetKeysAndFlags added in v3.5.4

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

func (*Client) CommandList added in v3.5.4

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

func (*Client) ConfigGet

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

func (*Client) ConfigResetStat

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

ConfigResetStat 重置 INFO 命令中的某些统计数据

func (*Client) ConfigRewrite

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

ConfigRewrite 对启动 Redis 服务器时所指定的 redis.conf 配置文件进行改写

func (*Client) ConfigSet

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

ConfigSet 修改 redis 配置参数,无需重启

func (*Client) Copy added in v3.2.31

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

Copy

func (*Client) DBSize

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

DBSize 返回当前数据库的 key 的数量

func (*Client) DebugObject

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

func (*Client) Decr

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

Decr 将 key 中储存的数字值减一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 DECR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 本操作的值限制在 64 位(bit)有符号数字表示之内。 关于递增(increment) / 递减(decrement)操作的更多信息,请参见 INCR 命令。 执行 DECR 命令之后 key 的值。

func (*Client) DecrBy

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

DecrBy 将 key 所储存的值减去减量 decrement 。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 DECRBY 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 本操作的值限制在 64 位(bit)有符号数字表示之内。 关于更多递增(increment) / 递减(decrement)操作的更多信息,请参见 INCR 命令。 减去 decrement 之后, key 的值。

func (*Client) Del

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

Del 删除给定的一个或多个 key 。 不存在的 key 会被忽略。

func (*Client) Dump

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

Dump 序列化给定 key ,并返回被序列化的值,使用 RESTORE 命令可以将这个值反序列化为 Redis 键。 如果 key 不存在,那么返回 nil 。 否则,返回序列化之后的值。

func (*Client) Echo

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

Echo 批量字符串回复

func (*Client) Eval

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

Eval 执行 Lua 脚本。

func (*Client) EvalRO added in v3.2.31

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

EvalRO 执行 Lua 脚本。

func (*Client) EvalSha

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

EvalSha 执行 Lua 脚本。

func (*Client) EvalShaRO added in v3.2.31

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

EvalShaRO 执行 Lua 脚本。

func (*Client) Exists

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

Exists 检查给定 key 是否存在。 若 key 存在,返回 1 ,否则返回 0 。

func (*Client) Expire

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

Expire 为给定 key 设置生存时间,当 key 过期时(生存时间为 0 ),它会被自动删除。 设置成功返回 1 。 当 key 不存在或者不能为 key 设置生存时间时(比如在低于 2.1.3 版本的 Redis 中你尝试更新 key 的生存时间),返回 0 。

func (*Client) ExpireAt

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

ExpireAt EXPIREAT 的作用和 EXPIRE 类似,都用于为 key 设置生存时间。 命令用于以 UNIX 时间戳(unix timestamp)格式设置 key 的过期时间

func (*Client) ExpireGT added in v3.2.31

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

ExpireGT ExpireGT 的作用和 EXPIRE 类似,都用于为 key 设置生存时间。 命令用于以 UNIX 时间戳(unix timestamp)格式设置 key 的过期时间

func (*Client) ExpireLT added in v3.2.31

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

ExpireLT ExpireLT 的作用和 EXPIRE 类似,都用于为 key 设置生存时间。 命令用于以 UNIX 时间戳(unix timestamp)格式设置 key 的过期时间

func (*Client) ExpireNX added in v3.2.31

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

ExpireNX ExpireNX 的作用和 EXPIRE 类似,都用于为 key 设置生存时间。 命令用于以 UNIX 时间戳(unix timestamp)格式设置 key 的过期时间

func (*Client) ExpireTime added in v3.5.4

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

func (*Client) ExpireXX added in v3.2.31

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

ExpireXX ExpireXX 的作用和 EXPIRE 类似,都用于为 key 设置生存时间。 命令用于以 UNIX 时间戳(unix timestamp)格式设置 key 的过期时间

func (*Client) FCall added in v3.5.4

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

func (*Client) FCallRO added in v3.6.1

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

func (*Client) FCallRo added in v3.5.4

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

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 - Performs a search query on an index and applies a series of aggregate transformations to the result. The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query. For more information, please refer to the Redis documentation: [FT.AGGREGATE]: (https://redis.io/commands/ft.aggregate/)

func (*Client) FTAggregateWithArgs added in v3.6.20

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

FTAggregateWithArgs - Performs a search query on an index and applies a series of aggregate transformations to the result. The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query. This function also allows for specifying additional options such as: Verbatim, LoadAll, Load, Timeout, GroupBy, SortBy, SortByMax, Apply, LimitOffset, Limit, Filter, WithCursor, Params, and DialectVersion. For more information, please refer to the Redis documentation: [FT.AGGREGATE]: (https://redis.io/commands/ft.aggregate/)

func (*Client) FTAliasAdd added in v3.6.20

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

FTAliasAdd - Adds an alias to an index. The 'index' parameter specifies the index to which the alias is added, and the 'alias' parameter specifies the alias. For more information, please refer to the Redis documentation: [FT.ALIASADD]: (https://redis.io/commands/ft.aliasadd/)

func (*Client) FTAliasDel added in v3.6.20

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

FTAliasDel - Removes an alias from an index. The 'alias' parameter specifies the alias to be removed. For more information, please refer to the Redis documentation: [FT.ALIASDEL]: (https://redis.io/commands/ft.aliasdel/)

func (*Client) FTAliasUpdate added in v3.6.20

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

FTAliasUpdate - Updates an alias to an index. The 'index' parameter specifies the index to which the alias is updated, and the 'alias' parameter specifies the alias. If the alias already exists for a different index, it updates the alias to point to the specified index instead. For more information, please refer to the Redis documentation: [FT.ALIASUPDATE]: (https://redis.io/commands/ft.aliasupdate/)

func (*Client) FTAlter added in v3.6.20

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

FTAlter - Alters the definition of an existing index. The 'index' parameter specifies the index to alter, and the 'skipInitalScan' parameter specifies whether to skip the initial scan. The 'definition' parameter specifies the new definition for the index. For more information, please refer to the Redis documentation: [FT.ALTER]: (https://redis.io/commands/ft.alter/)

func (*Client) FTConfigGet added in v3.6.20

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

FTConfigGet - Retrieves the value of a RediSearch configuration parameter. The 'option' parameter specifies the configuration parameter to retrieve. For more information, please refer to the Redis documentation: [FT.CONFIG GET]: (https://redis.io/commands/ft.config-get/)

func (*Client) FTConfigSet added in v3.6.20

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

FTConfigSet - Sets the value of a RediSearch configuration parameter. The 'option' parameter specifies the configuration parameter to set, and the 'value' parameter specifies the new value. For more information, please refer to the Redis documentation: [FT.CONFIG SET]: (https://redis.io/commands/ft.config-set/)

func (*Client) FTCreate added in v3.6.20

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

FTCreate - Creates a new index with the given options and schema. The 'index' parameter specifies the name of the index to create. The 'options' parameter specifies various options for the index, such as: whether to index hashes or JSONs, prefixes, filters, default language, score, score field, payload field, etc. The 'schema' parameter specifies the schema for the index, which includes the field name, field type, etc. For more information, please refer to the Redis documentation: [FT.CREATE]: (https://redis.io/commands/ft.create/)

func (*Client) FTCursorDel added in v3.6.20

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

FTCursorDel - Deletes a cursor from an existing index. The 'index' parameter specifies the index from which to delete the cursor, and the 'cursorId' parameter specifies the ID of the cursor to delete. For more information, please refer to the Redis documentation: [FT.CURSOR DEL]: (https://redis.io/commands/ft.cursor-del/)

func (*Client) FTCursorRead added in v3.6.20

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

FTCursorRead - Reads the next results from an existing cursor. The 'index' parameter specifies the index from which to read the cursor, the 'cursorId' parameter specifies the ID of the cursor to read, and the 'count' parameter specifies the number of results to read. For more information, please refer to the Redis documentation: [FT.CURSOR READ]: (https://redis.io/commands/ft.cursor-read/)

func (*Client) FTDictAdd added in v3.6.20

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

FTDictAdd - Adds terms to a dictionary. The 'dict' parameter specifies the dictionary to which to add the terms, and the 'term' parameter specifies the terms to add. For more information, please refer to the Redis documentation: [FT.DICTADD]: (https://redis.io/commands/ft.dictadd/)

func (*Client) FTDictDel added in v3.6.20

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

FTDictDel - Deletes terms from a dictionary. The 'dict' parameter specifies the dictionary from which to delete the terms, and the 'term' parameter specifies the terms to delete. For more information, please refer to the Redis documentation: [FT.DICTDEL]: (https://redis.io/commands/ft.dictdel/)

func (*Client) FTDictDump added in v3.6.20

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

FTDictDump - Returns all terms in the specified dictionary. The 'dict' parameter specifies the dictionary from which to return the terms. For more information, please refer to the Redis documentation: [FT.DICTDUMP]: (https://redis.io/commands/ft.dictdump/)

func (*Client) FTDropIndex added in v3.6.20

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

FTDropIndex - Deletes an index. The 'index' parameter specifies the index to delete. For more information, please refer to the Redis documentation: [FT.DROPINDEX]: (https://redis.io/commands/ft.dropindex/)

func (*Client) FTDropIndexWithArgs added in v3.6.20

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

FTDropIndexWithArgs - Deletes an index with options. The 'index' parameter specifies the index to delete, and the 'options' parameter specifies the DeleteDocs option for docs deletion. For more information, please refer to the Redis documentation: [FT.DROPINDEX]: (https://redis.io/commands/ft.dropindex/)

func (*Client) FTExplain added in v3.6.20

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

FTExplain - Returns the execution plan for a complex query. The 'index' parameter specifies the index to query, and the 'query' parameter specifies the query string. For more information, please refer to the Redis documentation: [FT.EXPLAIN]: (https://redis.io/commands/ft.explain/)

func (*Client) FTExplainCli added in v3.6.20

func (r *Client) FTExplainCli(ctx context.Context, key, path string) error

FTExplainCli - Returns the execution plan for a complex query. [Not Implemented] For more information, see https://redis.io/commands/ft.explaincli/

func (*Client) FTExplainWithArgs added in v3.6.20

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

FTExplainWithArgs - Returns the execution plan for a complex query with options. The 'index' parameter specifies the index to query, the 'query' parameter specifies the query string, and the 'options' parameter specifies the Dialect for the query. For more information, please refer to the Redis documentation: [FT.EXPLAIN]: (https://redis.io/commands/ft.explain/)

func (*Client) FTInfo added in v3.6.20

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

FTInfo - Retrieves information about an index. The 'index' parameter specifies the index to retrieve information about. For more information, please refer to the Redis documentation: [FT.INFO]: (https://redis.io/commands/ft.info/)

func (*Client) FTList added in v3.6.20

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

FT_List - Lists all the existing indexes in the database. For more information, please refer to the Redis documentation: [FT._LIST]: (https://redis.io/commands/ft._list/)

func (*Client) FTProfile added in v3.6.20

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

FTProfileSearch - Executes a search query and returns a profile of how the query was processed. The 'index' parameter specifies the index to search, the 'limited' parameter specifies whether to limit the results, and the 'query' parameter specifies the search / aggreagte query. Please notice that you must either pass a SearchQuery or an AggregateQuery. For more information, please refer to the Redis documentation: [FT.PROFILE SEARCH]: (https://redis.io/commands/ft.profile/)

func (*Client) FTSearch added in v3.6.20

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

FTSearch - Executes a search query on an index. The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query. For more information, please refer to the Redis documentation: [FT.SEARCH]: (https://redis.io/commands/ft.search/)

func (*Client) FTSearchWithArgs added in v3.6.20

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

FTSearchWithArgs - Executes a search query on an index with additional options. The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query, and the 'options' parameter specifies additional options for the search. For more information, please refer to the Redis documentation: [FT.SEARCH]: (https://redis.io/commands/ft.search/)

func (*Client) FTSpellCheck added in v3.6.20

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

FTSpellCheck - Checks a query string for spelling errors. For more details about spellcheck query please follow: https://redis.io/docs/interact/search-and-query/advanced-concepts/spellcheck/ For more information, please refer to the Redis documentation: [FT.SPELLCHECK]: (https://redis.io/commands/ft.spellcheck/)

func (*Client) FTSpellCheckWithArgs added in v3.6.20

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

FTSpellCheckWithArgs - Checks a query string for spelling errors with additional options. For more details about spellcheck query please follow: https://redis.io/docs/interact/search-and-query/advanced-concepts/spellcheck/ For more information, please refer to the Redis documentation: [FT.SPELLCHECK]: (https://redis.io/commands/ft.spellcheck/)

func (*Client) FTSynDump added in v3.6.20

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

FTSynDump - Dumps the synonyms data structure. The 'index' parameter specifies the index to dump. For more information, please refer to the Redis documentation: [FT.SYNDUMP]: (https://redis.io/commands/ft.syndump/)

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 - Creates or updates a synonym group with additional terms. The 'index' parameter specifies the index to update, the 'synGroupId' parameter specifies the synonym group id, and the 'terms' parameter specifies the additional terms. For more information, please refer to the Redis documentation: [FT.SYNUPDATE]: (https://redis.io/commands/ft.synupdate/)

func (*Client) FTSynUpdateWithArgs added in v3.6.20

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

FTSynUpdateWithArgs - Creates or updates a synonym group with additional terms and options. The 'index' parameter specifies the index to update, the 'synGroupId' parameter specifies the synonym group id, the 'options' parameter specifies additional options for the update, and the 'terms' parameter specifies the additional terms. For more information, please refer to the Redis documentation: [FT.SYNUPDATE]: (https://redis.io/commands/ft.synupdate/)

func (*Client) FTTagVals added in v3.6.20

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

FTTagVals - Returns all distinct values indexed in a tag field. The 'index' parameter specifies the index to check, and the 'field' parameter specifies the tag field to retrieve values from. For more information, please refer to the Redis documentation: [FT.TAGVALS]: (https://redis.io/commands/ft.tagvals/)

func (*Client) FlushAll

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

FlushAll 删除所有数据库的所有key

func (*Client) FlushAllAsync

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

FlushAllAsync 异步删除所有数据库的所有key

func (*Client) FlushDB

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

FlushDB 删除当前数据库的所有key

func (*Client) FlushDBAsync

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

FlushDBAsync 异步删除当前数据库的所有key

func (*Client) FunctionDelete added in v3.5.4

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

func (*Client) FunctionDump added in v3.5.4

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

func (*Client) FunctionFlush added in v3.5.4

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

func (*Client) FunctionFlushAsync added in v3.5.4

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

func (*Client) FunctionKill added in v3.5.4

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

func (*Client) FunctionList added in v3.5.4

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

func (*Client) FunctionLoad added in v3.5.4

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

func (*Client) FunctionLoadReplace added in v3.5.4

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

func (*Client) FunctionRestore added in v3.5.4

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

func (*Client) FunctionStats added in v3.5.4

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

func (*Client) GeoAdd

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

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

func (*Client) GeoDist

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

GeoDist 返回两个给定位置之间的距离

func (*Client) GeoHash

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

GeoHash 返回一个或多个位置元素的 Geohash 表示

func (*Client) GeoPos

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

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

func (*Client) GeoRadius

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

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

func (*Client) GeoRadiusByMember

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

GeoRadiusByMember -> GeoRadius

func (*Client) GeoRadiusByMemberStore

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

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

func (*Client) GeoRadiusStore

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

GeoRadiusStore -> GeoRadius

func (*Client) GeoSearch added in v3.2.31

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

func (*Client) GeoSearchLocation added in v3.2.31

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

func (*Client) GeoSearchStore added in v3.2.31

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

func (*Client) Get

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

Get 返回 key 所关联的字符串值。 如果 key 不存在那么返回特殊值 nil 。 假如 key 储存的值不是字符串类型,返回一个错误,因为 GET 只能用于处理字符串值。 当 key 不存在时,返回 nil ,否则,返回 key 的值。 如果 key 不是字符串类型,那么返回一个错误。

func (*Client) GetBit

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

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

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 any) (val string, err error)

GetEx

func (*Client) GetEx added in v3.2.31

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

GetEx

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 any, start, end int64) (val string, err error)

GetRange 返回 key 中字符串值的子字符串,字符串的截取范围由 start 和 end 两个偏移量决定(包括 start 和 end 在内)。 负数偏移量表示从字符串最后开始计数, -1 表示最后一个字符, -2 表示倒数第二个,以此类推。 GETRANGE 通过保证子字符串的值域(range)不超过实际字符串的值域来处理超出范围的值域请求。 返回截取得出的子字符串。

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 any, value any) (val string, err error)

GetSet 将给定 key 的值设为 value ,并返回 key 的旧值(old value)。 当 key 存在但不是字符串类型时,返回一个错误。 返回给定 key 的旧值。 当 key 没有旧值时,也即是, key 不存在时,返回 nil 。

func (*Client) HDel

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

HDel 删除哈希表 key 中的一个或多个指定域,不存在的域将被忽略。

func (*Client) HExists

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

HExists 查看哈希表 key 中,给定域 field 是否存在。

func (*Client) HGet

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

HGet 返回哈希表 key 中给定域 field 的值。

func (*Client) HGetAll

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

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

func (*Client) HIncrBy

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

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

func (*Client) HIncrByFloat

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

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

func (*Client) HKeys

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

HKeys 返回哈希表 key 中的所有域。

func (*Client) HLen

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

HLen 返回哈希表 key 中域的数量。

func (*Client) HMGet

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

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

func (*Client) HMSet

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

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

func (*Client) HRandField added in v3.2.31

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

func (*Client) HRandFieldWithValues added in v3.2.31

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

func (*Client) HScan

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

HScan 详细信息请参考 SCAN 命令。

func (*Client) HSet

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

HSet 将哈希表 key 中的域 field 的值设为 value 。 如果 key 不存在,一个新的哈希表被创建并进行 HSET 操作。 如果域 field 已经存在于哈希表中,旧值将被覆盖。

func (*Client) HSetNX

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

HSetNX 将哈希表 key 中的域 field 的值设置为 value ,当且仅当域 field 不存在。 若域 field 已经存在,该操作无效。 如果 key 不存在,一个新哈希表被创建并执行 HSETNX 命令。

func (*Client) HVals

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

HVals 返回哈希表 key 中所有域的值。

func (*Client) Incr

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

Incr 将 key 中储存的数字值增一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 本操作的值限制在 64 位(bit)有符号数字表示之内。 执行 INCR 命令之后 key 的值。

func (*Client) IncrBy

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

IncrBy 将 key 所储存的值加上增量 increment 。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCRBY 命令。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 本操作的值限制在 64 位(bit)有符号数字表示之内。 关于递增(increment) / 递减(decrement)操作的更多信息,参见 INCR 命令。 加上 increment 之后, key 的值。

func (*Client) IncrByFloat

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

IncrByFloat 为 key 中所储存的值加上浮点数增量 increment 。 如果 key 不存在,那么 INCRBYFLOAT 会先将 key 的值设为 0 ,再执行加法操作。 如果命令执行成功,那么 key 的值会被更新为(执行加法之后的)新值,并且新值会以字符串的形式返回给调用者。

func (*Client) Info

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

Info 获取 Redis 服务器的各种信息和统计数值

func (*Client) Keys

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

Keys 查找所有符合给定模式 pattern 的 key 。

func (*Client) LCS added in v3.5.4

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

func (*Client) LIndex

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

LIndex 返回列表 key 中,下标为 index 的元素。 下标(index)参数 start 和 stop 都以 0 为底,也就是说,以 0 表示列表的第一个元素,以 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 如果 key 不是列表类型,返回一个错误。

func (*Client) LInsert

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

LInsert 将值 value 插入到列表 key 当中,位于值 pivot 之前或之后。 当 pivot 不存在于列表 key 时,不执行任何操作。 当 key 不存在时, key 被视为空列表,不执行任何操作。 如果 key 不是列表类型,返回一个错误。

func (*Client) LInsertAfter

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

LInsertAfter 同 LInsert

func (*Client) LInsertBefore

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

LInsertBefore 同 LInsert

func (*Client) LLen

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

LLen 返回列表 key 的长度。 如果 key 不存在,则 key 被解释为一个空列表,返回 0 . 如果 key 不是列表类型,返回一个错误。

func (*Client) LMPop added in v3.5.4

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

LMPop Pops one or more elements from the first non-empty list key from the list of provided key names. direction: left or right, count: > 0 example: client.LMPop(ctx, "left", 3, "key1", "key2")

func (*Client) LMove added in v3.2.31

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

func (*Client) LPop

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

LPop 移除并返回列表 key 的头元素。

func (*Client) LPopCount added in v3.2.31

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

LPopCount 移除并返回列表 key 的头元素。

func (*Client) LPos added in v3.2.31

func (r *Client) LPos(ctx context.Context, key any, 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 any, value string, count int64, args redis.LPosArgs) (val []int64, err error)

func (*Client) LPush

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

LPush 将一个或多个值 value 插入到列表 key 的表头 如果有多个 value 值,那么各个 value 值按从左到右的顺序依次插入到表头 如果 key 不存在,一个空列表会被创建并执行 LPush 操作。 当 key 存在但不是列表类型时,返回一个错误。

func (*Client) LPushX

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

LPushX 将值 value 插入到列表 key 的表头,当且仅当 key 存在并且是一个列表。 和 LPUSH 命令相反,当 key 不存在时, LPUSHX 命令什么也不做。

func (*Client) LRange

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

LRange 返回列表 key 中指定区间内的元素,区间以偏移量 start 和 stop 指定。 下标(index)参数 start 和 stop 都以 0 为底,也就是说,以 0 表示列表的第一个元素,以 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。

func (*Client) LRem

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

LRem 根据参数 count 的值,移除列表中与参数 value 相等的元素。

func (*Client) LSet

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

LSet 将列表 key 下标为 index 的元素的值设置为 value 。 当 index 参数超出范围,或对一个空列表( key 不存在)进行 LSET 时,返回一个错误。 关于列表下标的更多信息,请参考 LINDEX 命令。

func (*Client) LTrim

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

LTrim 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。 举个例子,执行命令 LTRIM list 0 2 ,表示只保留列表 list 的前三个元素,其余元素全部删除。 下标(index)参数 start 和 stop 都以 0 为底,也就是说,以 0 表示列表的第一个元素,以 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 当 key 不是列表类型时,返回一个错误。

func (*Client) LastSave

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

LastSave 返回最近一次 Redis 成功将数据保存到磁盘上的时间,以 UNIX 时间戳格式表示

func (*Client) MGet

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

MGet 返回所有(一个或多个)给定 key 的值。 如果给定的 key 里面,有某个 key 不存在,那么这个 key 返回特殊值 nil 。因此,该命令永不失败。 一个包含所有给定 key 的值的列表。

func (*Client) MSet

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

MSet 同时设置一个或多个 key-value 对。

func (*Client) MSetNX

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

MSetNX 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在。 即使只有一个给定 key 已存在, MSETNX 也会拒绝执行所有给定 key 的设置操作。 MSETNX 是原子性的,因此它可以用作设置多个不同 key 表示不同字段(field)的唯一性逻辑对象(unique logic object),所有字段要么全被设置,要么全不被设置。

func (*Client) MemoryUsage

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

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 原子性地从当前实例传送到目标实例的指定数据库上,一旦传送成功, key 保证会出现在目标实例上,而当前实例上的 key 会被删除。

func (*Client) ModuleLoadex added in v3.6.1

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

func (*Client) Move

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

Move 将当前数据库的 key 移动到给定的数据库 db 当中。 如果当前数据库(源数据库)和给定数据库(目标数据库)有相同名字的给定 key ,或者 key 不存在于当前数据库,那么 MOVE 没有任何效果。

func (*Client) ObjectEncoding

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

ObjectEncoding 返回给定 key 锁储存的值所使用的内部表示(representation)。

func (*Client) ObjectIdleTime

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

ObjectIdleTime 返回给定 key 自储存以来的空转时间(idle, 没有被读取也没有被写入),以秒为单位。

func (*Client) ObjectRefCount

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

ObjectRefCount 返回给定 key 引用所储存的值的次数。此命令主要用于除错。

func (*Client) PExpire

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

PExpire 毫秒为单位设置 key 的生存时间

func (*Client) PExpireAt

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

PExpireAt 这个命令和 expireat 命令类似,但它以毫秒为单位设置 key 的过期 unix 时间戳,而不是像 expireat 那样,以秒为单位。 如果生存时间设置成功,返回 1 。 当 key 不存在或没办法设置生存时间时,返回 0

func (*Client) PExpireTime added in v3.5.4

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

func (*Client) PFAdd

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

PFAdd 将指定元素添加到HyperLogLog

func (*Client) PFCount

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

PFCount 返回HyperlogLog观察到的集合的近似基数。

func (*Client) PFMerge

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

PFMerge N个不同的HyperLogLog合并为一个。

func (*Client) PTTL

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

PTTL 这个命令类似于 TTL 命令,但它以毫秒为单位返回 key 的剩余生存时间,而不是像 TTL 命令那样,以秒为单位。 当 key 不存在时,返回 -2 。 当 key 存在但没有设置剩余生存时间时,返回 -1 。 否则,以毫秒为单位,返回 key 的剩余生存时间。

func (*Client) Persist

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

Persist 移除给定 key 的生存时间,将这个 key 从『易失的』(带生存时间 key )转换成『持久的』(一个不带生存时间、永不过期的 key )。 当生存时间移除成功时,返回 1 . 如果 key 不存在或 key 没有设置生存时间,返回 0 。

func (*Client) Ping

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

Ping 使用客户端向 Redis 服务器发送一个 PING ,如果服务器运作正常的话,会返回一个 PONG 。 通常用于测试与服务器的连接是否仍然生效,或者用于测量延迟值。 如果连接正常就返回一个 PONG ,否则返回一个连接错误。

func (*Client) Pipeline

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

Pipeline 获取管道

func (*Client) Pipelined

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

Pipelined 管道

func (*Client) Prefix

func (r *Client) Prefix(key string) string

Prefix 返回前缀+键

func (*Client) PubSubChannels

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

PubSubChannels 订阅一个或多个符合给定模式的频道。

func (*Client) PubSubNumPat

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

PubSubNumPat 用于获取redis订阅或者发布信息的状态

func (*Client) PubSubNumSub

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

func (*Client) PubSubShardChannels added in v3.2.31

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

PubSubShardChannels 订阅一个或多个符合给定模式的频道。

func (*Client) PubSubShardNumSub added in v3.2.31

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

func (*Client) Publish

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

Publish 将信息发送到指定的频道。

func (*Client) Quit

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

Quit 关闭连接

func (*Client) RPop

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

RPop 移除并返回列表 key 的头元素。

func (*Client) RPopCount added in v3.2.31

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

RPopCount 移除并返回列表 key 的头元素。

func (*Client) RPopLPush

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

RPopLPush 命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作: 将列表 source 中的最后一个元素(尾元素)弹出,并返回给客户端。 将 source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。 举个例子,你有两个列表 source 和 destination , source 列表有元素 a, b, c , destination 列表有元素 x, y, z ,执行 RPOPLPUSH source destination 之后, source 列表包含元素 a, b , destination 列表包含元素 c, x, y, z ,并且元素 c 会被返回给客户端。 如果 source 不存在,值 nil 被返回,并且不执行其他动作。 如果 source 和 destination 相同,则列表中的表尾元素被移动到表头,并返回该元素,可以把这种特殊情况视作列表的旋转(rotation)操作。

func (*Client) RPush

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

RPush 将一个或多个值 value 插入到列表 key 的表尾(最右边)。 如果有多个 value 值,那么各个 value 值按从左到右的顺序依次插入到表尾:比如对一个空列表 mylist 执行 RPUSH mylist a b c ,得出的结果列表为 a b c ,等同于执行命令 RPUSH mylist a 、 RPUSH mylist b 、 RPUSH mylist c 。 如果 key 不存在,一个空列表会被创建并执行 RPUSH 操作。 当 key 存在但不是列表类型时,返回一个错误。

func (*Client) RPushX

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

RPushX 将值 value 插入到列表 key 的表尾,当且仅当 key 存在并且是一个列表。 和 RPUSH 命令相反,当 key 不存在时, RPUSHX 命令什么也不做。

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)

func (*Client) ReadWrite

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

func (*Client) Rename

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

Rename 将 key 改名为 newkey 。 当 key 和 newkey 相同,或者 key 不存在时,返回一个错误。 当 newkey 已经存在时, RENAME 命令将覆盖旧值。

func (*Client) RenameNX

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

RenameNX 当且仅当 newkey 不存在时,将 key 改名为 newkey 。 当 key 不存在时,返回一个错误。

func (*Client) Restore

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

Restore 反序列化给定的序列化值,并将它和给定的 key 关联。 参数 ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间。 RESTORE 在执行反序列化之前会先对序列化值的 RDB 版本和数据校验和进行检查,如果 RDB 版本不相同或者数据不完整的话,那么 RESTORE 会拒绝进行反序列化,并返回一个错误。

func (*Client) RestoreReplace

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

RestoreReplace -> Restore

func (*Client) SAdd

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

SAdd 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略。 假如 key 不存在,则创建一个只包含 member 元素作成员的集合。 当 key 不是集合类型时,返回一个错误。

func (*Client) SCard

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

SCard 返回集合 key 的基数(集合中元素的数量)。

func (*Client) SDiff

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

SDiff 返回一个集合的全部成员,该集合是所有给定集合之间的差集。 不存在的 key 被视为空集。

func (*Client) SDiffStore

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

SDiffStore 这个命令的作用和 SDIFF 类似,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。

func (*Client) SInter

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

SInter 返回一个集合的全部成员,该集合是所有给定集合的交集。 不存在的 key 被视为空集。 当给定集合当中有一个空集时,结果也为空集(根据集合运算定律)。

func (*Client) SInterCard added in v3.2.31

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

SInterStore 这个命令类似于 SINTER 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。

func (*Client) SInterStore

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

SInterStore 这个命令类似于 SINTER 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 集合已经存在,则将其覆盖。 destination 可以是 key 本身。

func (*Client) SIsMember

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

SIsMember 判断 member 元素是否集合 key 的成员。

func (*Client) SMIsMember added in v3.6.12

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

func (*Client) SMembers

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

SMembers 返回集合 key 中的所有成员。 不存在的 key 被视为空集合。

func (*Client) SMembersMap

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

SMembersMap -> SMembers

func (*Client) SMove

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

SMove 将 member 元素从 source 集合移动到 destination 集合。 SMOVE 是原子性操作。 如果 source 集合不存在或不包含指定的 member 元素,则 SMOVE 命令不执行任何操作,仅返回 0 。否则, member 元素从 source 集合中被移除,并添加到 destination 集合中去。 当 destination 集合已经包含 member 元素时, SMOVE 命令只是简单地将 source 集合中的 member 元素删除。 当 source 或 destination 不是集合类型时,返回一个错误。

func (*Client) SPop

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

SPop 移除并返回集合中的一个随机元素。 如果只想获取一个随机元素,但不想该元素从集合中被移除的话,可以使用 SRANDMEMBER 命令。

func (*Client) SPopN

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

SPopN -> SPop

func (*Client) SPublish added in v3.2.31

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

SPublish 将信息发送到指定的频道。

func (*Client) SRandMember

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

SRandMember 如果命令执行时,只提供了 key 参数,那么返回集合中的一个随机元素。 从 Redis 2.6 版本开始, SRANDMEMBER 命令接受可选的 count 参数: 如果 count 为正数,且小于集合基数,那么命令返回一个包含 count 个元素的数组,数组中的元素各不相同。如果 count 大于等于集合基数,那么返回整个集合。 如果 count 为负数,那么命令返回一个数组,数组中的元素可能会重复出现多次,而数组的长度为 count 的绝对值。 该操作和 SPOP 相似,但 SPOP 将随机元素从集合中移除并返回,而 SRANDMEMBER 则仅仅返回随机元素,而不对集合进行任何改动。

func (*Client) SRandMemberN

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

SRandMemberN -> SRandMember

func (*Client) SRem

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

SRem 移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略。 当 key 不是集合类型,返回一个错误。

func (*Client) SScan

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

SScan 详细信息请参考 SCAN 命令。

func (*Client) SUnion

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

SUnion 返回一个集合的全部成员,该集合是所有给定集合的并集。 不存在的 key 被视为空集。

func (*Client) SUnionStore

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

SUnionStore 这个命令类似于 SUNION 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。 如果 destination 已经存在,则将其覆盖。 destination 可以是 key 本身。

func (*Client) Save

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

Save 异步保存数据到硬盘

func (*Client) Scan

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

Scan 命令及其相关的 SSCAN 命令、 HSCAN 命令和 ZSCAN 命令都用于增量地迭代(incrementally iterate)一集元素

func (*Client) ScanIterator added in v3.5.0

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

func (*Client) ScanType added in v3.2.31

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

func (*Client) ScriptExists

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

ScriptExists 查看指定的脚本是否已经被保存在缓存当中。

func (*Client) ScriptFlush

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

ScriptFlush 从脚本缓存中移除所有脚本。

func (*Client) ScriptKill

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

ScriptKill 杀死当前正在运行的 Lua 脚本。

func (*Client) ScriptLoad

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

ScriptLoad 将脚本 script 添加到脚本缓存中,但并不立即执行这个脚本。

func (*Client) Set

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

Set 将字符串值 value 关联到 key 。 如果 key 已经持有其他值, SET 就覆写旧值,无视类型。 对于某个原本带有生存时间(TTL)的键来说, 当 SET 命令成功在这个键上执行时, 这个键原有的 TTL 将被清除。

func (*Client) SetArgs added in v3.2.31

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

func (*Client) SetBit

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

SetBit 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。 位的设置或清除取决于 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 any, value any, expiration time.Duration) (val string, err error)

SetEX ...

func (*Client) SetNX

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

SetNX 将 key 的值设为 value ,当且仅当 key 不存在。 若给定的 key 已经存在,则 SETNX 不做任何动作。 SETNX 是『SET if Not eXists』(如果不存在,则 SET)的简写。

func (*Client) SetRange

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

SetRange 用 value 参数覆写(overwrite)给定 key 所储存的字符串值,从偏移量 offset 开始。 不存在的 key 当作空白字符串处理。

func (*Client) SetXX

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

SetXX -> SetNX

func (*Client) Shutdown

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

Shutdown 关闭服务器

func (*Client) ShutdownNoSave

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

ShutdownNoSave 不保存数据到硬盘,并关闭服务器

func (*Client) ShutdownSave

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

ShutdownSave 异步保存数据到硬盘,并关闭服务器

func (*Client) SlaveOf

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

SlaveOf 将当前服务器转变为指定服务器的从属服务器(slave server)

func (*Client) SlowLogGet added in v3.2.31

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

func (*Client) Sort

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

Sort 返回或保存给定列表、集合、有序集合 key 中经过排序的元素。 排序默认以数字作为对象,值被解释为双精度浮点数,然后进行比较。

func (*Client) SortInterfaces

func (r *Client) SortInterfaces(ctx context.Context, key any, 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 any, sort *redis.Sort) (val []string, err error)

func (*Client) SortStore

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

SortStore -> Sort

func (*Client) StrLen

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

StrLen 返回 key 所储存的字符串值的长度。 当 key 储存的不是字符串值时,返回一个错误。

func (*Client) TFCall added in v3.6.12

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

func (*Client) TFCallASYNC added in v3.6.12

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

func (*Client) TFCallASYNCArgs added in v3.6.12

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

func (*Client) TFCallArgs added in v3.6.12

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

func (*Client) TFunctionDelete added in v3.6.12

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

func (*Client) TFunctionList added in v3.6.12

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

func (*Client) TFunctionListArgs added in v3.6.12

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

func (*Client) TFunctionLoad added in v3.6.12

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

func (*Client) TFunctionLoadArgs added in v3.6.12

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

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)

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)

func (*Client) TSAlter added in v3.6.12

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

func (*Client) TSCreate added in v3.6.12

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

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)

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)

func (*Client) TSCreateWithArgs added in v3.6.12

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

func (*Client) TSDecrBy added in v3.6.12

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

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)

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)

func (*Client) TSDeleteRule added in v3.6.12

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

func (*Client) TSGet added in v3.6.12

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

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)

func (*Client) TSIncrBy added in v3.6.12

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

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)

func (*Client) TSInfo added in v3.6.12

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

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)

func (*Client) TSMAdd added in v3.6.12

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

func (*Client) TSMGet added in v3.6.12

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

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)

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)

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)

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)

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)

func (*Client) TSQueryIndex added in v3.6.12

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

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)

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)

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)

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)

func (*Client) TTL

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

TTL 以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)。 当 key 不存在时,返回 -2 。 当 key 存在但没有设置剩余生存时间时,返回 -1 。 否则,以秒为单位,返回 key 的剩余生存时间。

func (*Client) Time

func (r *Client) Time(ctx context.Context) (val time.Time, err error)

Time 返回当前服务器时间

func (*Client) Touch

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

Touch 更改键的上次访问时间。返回指定的现有键的数量。

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 管道

func (*Client) Type

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

Type 返回 key 所储存的值的类型。

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

Unlink 这个命令非常类似于DEL:它删除指定的键。就像DEL键一样,如果它不存在,它将被忽略。但是,该命令在不同的线程中执行实际的内存回收,所以它不会阻塞,而DEL是。这是命令名称的来源:命令只是将键与键空间断开连接。实际删除将在以后异步发生。

func (*Client) XAck

func (r *Client) XAck(ctx context.Context, stream any, group string, ids ...string) (val int64, err error)

XAck command

func (*Client) XAdd

func (r *Client) XAdd(ctx context.Context, a *redis.XAddArgs) (val string, err error)

XAdd 将指定的流条目追加到指定key的流中。 如果key不存在,作为运行这个命令的副作用,将使用流的条目自动创建key。

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)

func (*Client) XAutoClaimJustID added in v3.2.31

func (r *Client) XAutoClaimJustID(ctx context.Context, a *redis.XAutoClaimArgs) (val []string, start string, err error)

func (*Client) XClaim

func (r *Client) XClaim(ctx context.Context, a *redis.XClaimArgs) (val []redis.XMessage, err error)

XClaim command

func (*Client) XClaimJustID

func (r *Client) XClaimJustID(ctx context.Context, a *redis.XClaimArgs) (val []string, err error)

XClaimJustID command

func (*Client) XDel

func (r *Client) XDel(ctx context.Context, stream any, ids ...string) (val int64, err error)

XDel 从指定流中移除指定的条目,并返回成功删除的条目的数量,在传递的ID不存在的情况下, 返回的数量可能与传递的ID数量不同。

func (*Client) XGroupCreate

func (r *Client) XGroupCreate(ctx context.Context, stream any, group, start string) (val string, err error)

XGroupCreate command

func (*Client) XGroupCreateMkStream

func (r *Client) XGroupCreateMkStream(ctx context.Context, stream any, group, start string) (val string, err error)

XGroupCreateMkStream command

func (*Client) XGroupDelConsumer

func (r *Client) XGroupDelConsumer(ctx context.Context, stream any, group, consumer string) (val int64, err error)

XGroupDelConsumer command

func (*Client) XGroupDestroy

func (r *Client) XGroupDestroy(ctx context.Context, stream any, group string) (val int64, err error)

XGroupDestroy command

func (*Client) XGroupSetID

func (r *Client) XGroupSetID(ctx context.Context, stream any, group, start string) (val string, err error)

XGroupSetID command

func (*Client) XInfoConsumers added in v3.2.31

func (r *Client) XInfoConsumers(ctx context.Context, key any, group string) (val []redis.XInfoConsumer, err error)

func (*Client) XInfoGroups

func (r *Client) XInfoGroups(ctx context.Context, key any) (val []redis.XInfoGroup, err error)

XInfoGroups command

func (*Client) XInfoStream added in v3.2.31

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

func (*Client) XInfoStreamFull added in v3.2.31

func (r *Client) XInfoStreamFull(ctx context.Context, key any, count int) (val *redis.XInfoStreamFull, err error)

func (*Client) XLen

func (r *Client) XLen(ctx context.Context, stream any) (val int64, err error)

XLen 返回流中的条目数。如果指定的key不存在,则此命令返回0,就好像该流为空。 但是请注意,与其他的Redis类型不同,零长度流是可能的,所以你应该调用TYPE 或者 EXISTS 来检查一个key是否存在。 一旦内部没有任何的条目(例如调用XDEL后),流不会被自动删除,因为可能还存在与其相关联的消费者组。

func (*Client) XPending

func (r *Client) XPending(ctx context.Context, stream any, group string) (val *redis.XPending, err error)

XPending command

func (*Client) XPendingExt

func (r *Client) XPendingExt(ctx context.Context, a *redis.XPendingExtArgs) (val []redis.XPendingExt, err error)

XPendingExt command

func (*Client) XRange

func (r *Client) XRange(ctx context.Context, stream any, start, stop string) (val []redis.XMessage, err error)

XRange 此命令返回流中满足给定ID范围的条目。范围由最小和最大ID指定。所有ID在指定的两个ID之间或与其中一个ID相等(闭合区间)的条目将会被返回。

func (*Client) XRangeN

func (r *Client) XRangeN(ctx context.Context, stream any, start, stop string, count int64) (val []redis.XMessage, err error)

XRangeN -> XRange

func (*Client) XRead

func (r *Client) XRead(ctx context.Context, a *redis.XReadArgs) (val []redis.XStream, err error)

XRead 从一个或者多个流中读取数据,仅返回ID大于调用者报告的最后接收ID的条目。此命令有一个阻塞选项,用于等待可用的项目,类似于BRPOP或者BZPOPMIN等等。

func (*Client) XReadGroup

func (r *Client) XReadGroup(ctx context.Context, a *redis.XReadGroupArgs) (val []redis.XStream, err error)

XReadGroup command

func (*Client) XReadStreams

func (r *Client) XReadStreams(ctx context.Context, streams ...any) (val []redis.XStream, err error)

XReadStreams -> XRead

func (*Client) XRevRange

func (r *Client) XRevRange(ctx context.Context, stream any, start, stop string) (val []redis.XMessage, err error)

XRevRange 此命令与XRANGE完全相同,但显著的区别是以相反的顺序返回条目,并以相反的顺序获取开始-结束参数:在XREVRANGE中,你需要先指定结束ID,再指定开始ID,该命令就会从结束ID侧开始生成两个ID之间(或完全相同)的所有元素。

func (*Client) XRevRangeN

func (r *Client) XRevRangeN(ctx context.Context, stream any, start, stop string, count int64) (val []redis.XMessage, err error)

XRevRangeN -> XRevRange

func (*Client) XTrimMaxLen added in v3.2.31

func (r *Client) XTrimMaxLen(ctx context.Context, key any, maxLen int64) (val int64, err error)

func (*Client) XTrimMaxLenApprox added in v3.2.31

func (r *Client) XTrimMaxLenApprox(ctx context.Context, key any, maxLen, limit int64) (val int64, err error)

func (*Client) XTrimMinID added in v3.2.31

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

func (*Client) XTrimMinIDApprox added in v3.2.31

func (r *Client) XTrimMinIDApprox(ctx context.Context, key any, minID string, limit int64) (val int64, err error)

func (*Client) ZAdd

func (r *Client) ZAdd(ctx context.Context, key any, members ...redis.Z) (val int64, err error)

ZAdd 将一个或多个 member 元素及其 score 值加入到有序集 key 当中。 如果某个 member 已经是有序集的成员,那么更新这个 member 的 score 值,并通过重新插入这个 member 元素,来保证该 member 在正确的位置上。 score 值可以是整数值或双精度浮点数。 如果 key 不存在,则创建一个空的有序集并执行 ZADD 操作。 当 key 存在但不是有序集类型时,返回一个错误。

func (*Client) ZAddArgs added in v3.2.31

func (r *Client) ZAddArgs(ctx context.Context, key any, args redis.ZAddArgs) (val int64, err error)

func (*Client) ZAddArgsIncr added in v3.2.31

func (r *Client) ZAddArgsIncr(ctx context.Context, key any, args redis.ZAddArgs) (val float64, err error)

func (*Client) ZAddGT added in v3.6.12

func (r *Client) ZAddGT(ctx context.Context, key any, members ...redis.Z) (val int64, err error)

func (*Client) ZAddLT added in v3.6.12

func (r *Client) ZAddLT(ctx context.Context, key any, members ...redis.Z) (val int64, err error)

func (*Client) ZAddNX

func (r *Client) ZAddNX(ctx context.Context, key any, members ...redis.Z) (val int64, err error)

ZAddNX -> ZAdd

func (*Client) ZAddXX

func (r *Client) ZAddXX(ctx context.Context, key any, members ...redis.Z) (val int64, err error)

ZAddXX -> ZAdd

func (*Client) ZCard

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

ZCard 返回有序集 key 的基数。

func (*Client) ZCount

func (r *Client) ZCount(ctx context.Context, key any, min, max string) (val int64, err error)

ZCount 返回有序集 key 中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数量。 关于参数 min 和 max 的详细使用方法,请参考 ZRANGEBYSCORE 命令。

func (*Client) ZDiff added in v3.2.31

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

func (*Client) ZDiffStore added in v3.2.31

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

func (*Client) ZDiffWithScores added in v3.2.31

func (r *Client) ZDiffWithScores(ctx context.Context, keys ...any) (val []redis.Z, err error)

func (*Client) ZIncrBy

func (r *Client) ZIncrBy(ctx context.Context, key any, increment float64, member string) (val float64, err error)

ZIncrBy 为有序集 key 的成员 member 的 score 值加上增量 increment 。 可以通过传递一个负数值 increment ,让 score 减去相应的值,比如 ZINCRBY key -5 member ,就是让 member 的 score 值减去 5 。 当 key 不存在,或 member 不是 key 的成员时, ZINCRBY key increment member 等同于 ZADD key increment member 。 当 key 不是有序集类型时,返回一个错误。 score 值可以是整数值或双精度浮点数。

func (*Client) ZInter added in v3.2.31

func (r *Client) ZInter(ctx context.Context, store *redis.ZStore) (val []string, err error)

ZInter 计算给定的一个或多个有序集的交集,其中给定 key 的数量必须以 numkeys 参数指定,并将该交集(结果集)储存到 destination 。 默认情况下,结果集中某个成员的 score 值是所有给定集下该成员 score 值之和. 关于 WEIGHTS 和 AGGREGATE 选项的描述,参见 ZUNIONSTORE 命令。

func (*Client) ZInterCard added in v3.2.31

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

func (*Client) ZInterStore

func (r *Client) ZInterStore(ctx context.Context, key any, store *redis.ZStore) (val int64, err error)

ZInterStore 计算给定的一个或多个有序集的交集,其中给定 key 的数量必须以 numkeys 参数指定,并将该交集(结果集)储存到 destination 。 默认情况下,结果集中某个成员的 score 值是所有给定集下该成员 score 值之和. 关于 WEIGHTS 和 AGGREGATE 选项的描述,参见 ZUNIONSTORE 命令。

func (*Client) ZInterWithScores added in v3.2.31

func (r *Client) ZInterWithScores(ctx context.Context, store *redis.ZStore) (val []redis.Z, err error)

func (*Client) ZLexCount

func (r *Client) ZLexCount(ctx context.Context, key any, min, max string) (val int64, err error)

ZLexCount -> ZCount

func (*Client) ZMPop added in v3.5.4

func (r *Client) ZMPop(ctx context.Context, order string, count int64, keys ...any) (key string, ret []redis.Z, err error)

func (*Client) ZMScore added in v3.2.31

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

func (*Client) ZPopMax

func (r *Client) ZPopMax(ctx context.Context, key any, count ...int64) (val []redis.Z, err error)

ZPopMax 删除并返回有序集合key中的最多count个具有最高得分的成员。

func (*Client) ZPopMin

func (r *Client) ZPopMin(ctx context.Context, key any, count ...int64) (val []redis.Z, err error)

ZPopMin 删除并返回有序集合key中的最多count个具有最低得分的成员。

func (*Client) ZRandMember added in v3.2.31

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

func (*Client) ZRandMemberWithScores added in v3.2.31

func (r *Client) ZRandMemberWithScores(ctx context.Context, key any, count int) (val []redis.Z, err error)

func (*Client) ZRange

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

ZRange 返回有序集 key 中,指定区间内的成员。 其中成员的位置按 score 值递增(从小到大)来排序。

func (*Client) ZRangeArgs added in v3.2.31

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

func (*Client) ZRangeArgsWithScores added in v3.2.31

func (r *Client) ZRangeArgsWithScores(ctx context.Context, z redis.ZRangeArgs) (val []redis.Z, err error)

func (*Client) ZRangeByLex

func (r *Client) ZRangeByLex(ctx context.Context, key any, opt *redis.ZRangeBy) (val []string, err error)

ZRangeByLex -> ZRangeByScore

func (*Client) ZRangeByScore

func (r *Client) ZRangeByScore(ctx context.Context, key any, opt *redis.ZRangeBy) (val []string, err error)

ZRangeByScore 返回有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。有序集成员按 score 值递增(从小到大)次序排列。

func (*Client) ZRangeByScoreWithScores

func (r *Client) ZRangeByScoreWithScores(ctx context.Context, key any, opt *redis.ZRangeBy) (val []redis.Z, err error)

ZRangeByScoreWithScores -> ZRangeByScore

func (*Client) ZRangeStore added in v3.2.31

func (r *Client) ZRangeStore(ctx context.Context, dst any, z redis.ZRangeArgs) (val int64, err error)

func (*Client) ZRangeWithScores

func (r *Client) ZRangeWithScores(ctx context.Context, key any, start, stop int64) (val []redis.Z, err error)

ZRangeWithScores -> ZRange

func (*Client) ZRank

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

ZRank 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列。 排名以 0 为底,也就是说, score 值最小的成员排名为 0 。 使用 ZREVRANK 命令可以获得成员按 score 值递减(从大到小)排列的排名。

func (*Client) ZRankWithScore added in v3.6.1

func (r *Client) ZRankWithScore(ctx context.Context, key any, member string) (val redis.RankScore, err error)

func (*Client) ZRem

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

ZRem 移除有序集 key 中的一个或多个成员,不存在的成员将被忽略。 当 key 存在但不是有序集类型时,返回一个错误。

func (*Client) ZRemRangeByLex

func (r *Client) ZRemRangeByLex(ctx context.Context, key any, min, max string) (val int64, err error)

ZRemRangeByLex -> ZRemRangeByScore

func (*Client) ZRemRangeByRank

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

ZRemRangeByRank 移除有序集 key 中,指定排名(rank)区间内的所有成员。 区间分别以下标参数 start 和 stop 指出,包含 start 和 stop 在内。 下标参数 start 和 stop 都以 0 为底,也就是说,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。 你也可以使用负数下标,以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推

func (*Client) ZRemRangeByScore

func (r *Client) ZRemRangeByScore(ctx context.Context, key any, min, max string) (val int64, err error)

ZRemRangeByScore 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。 自版本2.1.6开始, score 值等于 min 或 max 的成员也可以不包括在内,详情请参见 ZRANGEBYSCORE 命令。

func (*Client) ZRevRange

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

ZRevRange 返回有序集 key 中,指定区间内的成员。 其中成员的位置按 score 值递减(从大到小)来排列。 具有相同 score 值的成员按字典序的逆序(reverse lexicographical order)排列。 除了成员按 score 值递减的次序排列这一点外, ZREVRANGE 命令的其他方面和 ZRANGE 命令一样。

func (*Client) ZRevRangeByLex

func (r *Client) ZRevRangeByLex(ctx context.Context, key any, opt *redis.ZRangeBy) (val []string, err error)

ZRevRangeByLex -> ZRevRangeByScore

func (*Client) ZRevRangeByScore

func (r *Client) ZRevRangeByScore(ctx context.Context, key any, opt *redis.ZRangeBy) (val []string, err error)

ZRevRangeByScore 返回有序集 key 中, score 值介于 max 和 min 之间(默认包括等于 max 或 min )的所有的成员。有序集成员按 score 值递减(从大到小)的次序排列。 具有相同 score 值的成员按字典序的逆序(reverse lexicographical order )排列。 除了成员按 score 值递减的次序排列这一点外, ZREVRANGEBYSCORE 命令的其他方面和 ZRANGEBYSCORE 命令一样。

func (*Client) ZRevRangeByScoreWithScores

func (r *Client) ZRevRangeByScoreWithScores(ctx context.Context, key any, opt *redis.ZRangeBy) (val []redis.Z, err error)

ZRevRangeByScoreWithScores -> ZRevRangeByScore

func (*Client) ZRevRangeWithScores

func (r *Client) ZRevRangeWithScores(ctx context.Context, key any, start, stop int64) (val []redis.Z, err error)

ZRevRangeWithScores -> ZRevRange

func (*Client) ZRevRank

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

ZRevRank 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递减(从大到小)排序。 排名以 0 为底,也就是说, score 值最大的成员排名为 0 。 使用 ZRANK 命令可以获得成员按 score 值递增(从小到大)排列的排名。

func (*Client) ZRevRankWithScore added in v3.6.1

func (r *Client) ZRevRankWithScore(ctx context.Context, key any, member string) (val redis.RankScore, err error)

func (*Client) ZScan

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

ZScan 详细信息请参考 SCAN 命令。

func (*Client) ZScore

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

ZScore 返回有序集 key 中,成员 member 的 score 值。 如果 member 元素不是有序集 key 的成员,或 key 不存在,返回 nil 。

func (*Client) ZUnion added in v3.2.31

func (r *Client) ZUnion(ctx context.Context, store redis.ZStore) (val []string, err error)

func (*Client) ZUnionStore

func (r *Client) ZUnionStore(ctx context.Context, dest any, store *redis.ZStore) (val int64, err error)

ZUnionStore 计算给定的一个或多个有序集的并集,其中给定 key 的数量必须以 numkeys 参数指定,并将该并集(结果集)储存到 destination 。 默认情况下,结果集中某个成员的 score 值是所有给定集下该成员 score 值之 和 。

func (*Client) ZUnionWithScores added in v3.2.31

func (r *Client) ZUnionWithScores(ctx context.Context, store redis.ZStore) (val []redis.Z, err error)

type CmdStart added in v3.1.6

type CmdStart string

CmdStart ...

type FTAggregateApply added in v3.6.20

type FTAggregateApply struct {
	Field string
	As    string
}

type FTAggregateGroupBy added in v3.6.20

type FTAggregateGroupBy struct {
	Fields []any
	Reduce []FTAggregateReducer
}

type FTAggregateLoad added in v3.6.20

type FTAggregateLoad struct {
	Field string
	As    string
}

type FTAggregateOptions added in v3.6.20

type FTAggregateOptions struct {
	Verbatim          bool
	LoadAll           bool
	Load              []FTAggregateLoad
	Timeout           int
	GroupBy           []FTAggregateGroupBy
	SortBy            []FTAggregateSortBy
	SortByMax         int
	Apply             []FTAggregateApply
	LimitOffset       int
	Limit             int
	Filter            string
	WithCursor        bool
	WithCursorOptions *FTAggregateWithCursor
	Params            map[string]any
	DialectVersion    int
}

type FTAggregateReducer added in v3.6.20

type FTAggregateReducer struct {
	Reducer SearchAggregator
	Args    []any
	As      string
}

Each AggregateReducer have different args. Please follow https://redis.io/docs/interact/search-and-query/search/aggregations/#supported-groupby-reducers for more information.

type FTAggregateSortBy added in v3.6.20

type FTAggregateSortBy struct {
	FieldName string
	Asc       bool
	Desc      bool
}

type FTAggregateWithCursor added in v3.6.20

type FTAggregateWithCursor struct {
	Count   int
	MaxIdle int
}

type FTCreateOptions added in v3.6.20

type FTCreateOptions struct {
	OnHash          bool
	OnJSON          bool
	Prefix          []any
	Filter          string
	DefaultLanguage string
	LanguageField   string
	Score           float64
	ScoreField      string
	PayloadField    string
	MaxTextFields   int
	NoOffsets       bool
	Temporary       int
	NoHL            bool
	NoFields        bool
	NoFreqs         bool
	StopWords       []any
	SkipInitalScan  bool
}

type FTDropIndexOptions added in v3.6.20

type FTDropIndexOptions struct {
	DeleteDocs bool
}

type FTExplainOptions added in v3.6.20

type FTExplainOptions struct {
	Dialect string
}

type FTFlatOptions added in v3.6.20

type FTFlatOptions struct {
	Type            string
	Dim             int
	DistanceMetric  string
	InitialCapacity int
	BlockSize       int
}

type FTHNSWOptions added in v3.6.20

type FTHNSWOptions struct {
	Type                   string
	Dim                    int
	DistanceMetric         string
	InitialCapacity        int
	MaxEdgesPerNode        int
	MaxAllowedEdgesPerNode int
	EFRunTime              int
	Epsilon                float64
}

type FTSearchFilter added in v3.6.20

type FTSearchFilter struct {
	FieldName any
	Min       any
	Max       any
}

type FTSearchGeoFilter added in v3.6.20

type FTSearchGeoFilter struct {
	FieldName string
	Longitude float64
	Latitude  float64
	Radius    float64
	Unit      string
}

type FTSearchOptions added in v3.6.20

type FTSearchOptions struct {
	NoContent       bool
	Verbatim        bool
	NoStopWrods     bool
	WithScores      bool
	WithPayloads    bool
	WithSortKeys    bool
	Filters         []FTSearchFilter
	GeoFilter       []FTSearchGeoFilter
	InKeys          []any
	InFields        []any
	Return          []FTSearchReturn
	Slop            int
	Timeout         int
	InOrder         bool
	Language        string
	Expander        string
	Scorer          string
	ExplainScore    bool
	Payload         string
	SortBy          []FTSearchSortBy
	SortByWithCount bool
	LimitOffset     int
	Limit           int
	Params          map[string]any
	DialectVersion  int
}

type FTSearchReturn added in v3.6.20

type FTSearchReturn struct {
	FieldName string
	As        string
}

type FTSearchSortBy added in v3.6.20

type FTSearchSortBy struct {
	FieldName string
	Asc       bool
	Desc      bool
}

type FTSpellCheckOptions added in v3.6.20

type FTSpellCheckOptions struct {
	Distance int
	Terms    SpellCheckTerms
	Dialect  int
}

type FTSynUpdateOptions added in v3.6.20

type FTSynUpdateOptions struct {
	SkipInitialScan bool
}

type FTVectorArgs added in v3.6.20

type FTVectorArgs struct {
	FlatOptions *FTFlatOptions
	HNSWOptions *FTHNSWOptions
}

type FieldSchema added in v3.6.20

type FieldSchema struct {
	FieldName         string
	As                string
	FieldType         SearchFieldType
	Sortable          bool
	UNF               bool
	NoStem            bool
	NoIndex           bool
	PhoneticMatcher   string
	Weight            float64
	Seperator         string
	CaseSensitive     bool
	WithSuffixtrie    bool
	VectorArgs        *FTVectorArgs
	GeoShapeFieldType string
}

type OpenTraceHook

type OpenTraceHook struct {
	redis.Hook
	DisableMetric bool // 关闭指标采集
	DisableTrace  bool // 关闭链路追踪
	DB            int
	Addr          string
}

OpenTraceHook ...

func (OpenTraceHook) AfterProcess

func (op OpenTraceHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error

AfterProcess ...

func (OpenTraceHook) AfterProcessPipeline

func (op OpenTraceHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error

AfterProcessPipeline ...

func (OpenTraceHook) BeforeProcess

func (op OpenTraceHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error)

BeforeProcess ...

func (OpenTraceHook) BeforeProcessPipeline

func (op OpenTraceHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error)

BeforeProcessPipeline ...

func (OpenTraceHook) DialHook added in v3.2.33

func (op OpenTraceHook) DialHook(hook redis.DialHook) redis.DialHook

func (OpenTraceHook) ProcessHook added in v3.2.33

func (op OpenTraceHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook

func (OpenTraceHook) ProcessPipelineHook added in v3.2.34

func (op OpenTraceHook) ProcessPipelineHook(hook redis.ProcessPipelineHook) redis.ProcessPipelineHook

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 customizes the given Redis with given Addr.

func WithAddrs added in v3.4.2

func WithAddrs(Addrs map[string]string) Option

WithAddrs customizes the given Redis with given Addrs.

func WithClientType added in v3.4.3

func WithClientType(ClientType string) Option

WithClientType customizes the given Redis with given Type.

func WithDatabase added in v3.4.2

func WithDatabase(Database int) Option

WithDatabase customizes the given Redis with given Database.

func WithDisableMetric added in v3.4.2

func WithDisableMetric(DisableMetric bool) Option

WithDisableMetric customizes the given Redis with given DisableMetric.

func WithDisableTrace added in v3.4.2

func WithDisableTrace(DisableTrace bool) Option

WithDisableTrace customizes the given Redis with given DisableTrace.

func WithHosts added in v3.4.2

func WithHosts(Hosts []string) Option

WithHosts customizes the given Redis with given Hosts.

func WithKeyPrefix added in v3.4.2

func WithKeyPrefix(KeyPrefix string) Option

WithKeyPrefix customizes the given Redis with given KeyPrefix.

func WithMasterName added in v3.4.2

func WithMasterName(MasterName string) Option

WithMasterName customizes the given Redis with given MasterName.

func WithPassword added in v3.4.2

func WithPassword(Password string) Option

WithPassword customizes the given Redis with given Password.

func WithPoolSize added in v3.4.2

func WithPoolSize(PoolSize int) Option

WithPoolSize customizes the given Redis with given 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
	redis.BitMapCmdable
}

RedisNode interface represents a redis node.

type SearchAggregator added in v3.6.20

type SearchAggregator int

func (SearchAggregator) String added in v3.6.20

func (a SearchAggregator) String() string

type SearchFieldType added in v3.6.20

type SearchFieldType int

func (SearchFieldType) String added in v3.6.20

func (t SearchFieldType) String() string

type SearchQuery added in v3.6.20

type SearchQuery []any

func FTSearchQuery added in v3.6.20

func FTSearchQuery(query string, options *FTSearchOptions) SearchQuery

type SpellCheckTerms added in v3.6.20

type SpellCheckTerms struct {
	Include    bool
	Exclude    bool
	Dictionary string
}

Jump to

Keyboard shortcuts

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