Documentation
¶
Overview ¶
Package redis 提供了 Redis 客户端的基础类型和命令定义。
Package redis 提供了 Redis 操作的扩展功能实现。
Index ¶
- Variables
- type ACLLogCmd
- type ACLLogEntry
- type BitCount
- type BoolCmd
- type BoolSliceCmd
- type ClientFlags
- type ClientInfo
- type ClientInfoCmd
- type ClusterLink
- type ClusterLinksCmd
- type ClusterNode
- type ClusterShard
- type ClusterShardsCmd
- type ClusterSlot
- type ClusterSlotsCmd
- type Cmd
- type Cmder
- type CommandInfo
- type CommandsInfoCmd
- type DurationCmd
- type Engine
- type FilterBy
- type FloatCmd
- type FloatSliceCmd
- type Function
- type FunctionListCmd
- type FunctionListQuery
- type FunctionStats
- type FunctionStatsCmd
- type GeoLocation
- type GeoLocationCmd
- type GeoPos
- type GeoPosCmd
- type GeoRadiusQuery
- type GeoSearchLocationCmd
- type GeoSearchLocationQuery
- type GeoSearchQuery
- type GeoSearchStoreQuery
- type IntCmd
- type IntSliceCmd
- type KeyFlags
- type KeyFlagsCmd
- type KeyValue
- type KeyValueSliceCmd
- type KeyValuesCmd
- type LCSCmd
- type LCSMatch
- type LCSMatchedPosition
- type LCSPosition
- type LCSQuery
- type LPosArgs
- type Library
- type MapStringIntCmd
- type MapStringInterfaceCmd
- type MapStringStringCmd
- type MapStringStringSliceCmd
- type Message
- type ModuleLoadexConfig
- type Node
- type Option
- type Pipeliner
- type Pong
- type PubSub
- type RankScore
- type RankWithScoreCmd
- type Redis
- type RedisExtension
- type RunningScript
- type ScanCmd
- type Scripter
- type SetArgs
- type SliceCmd
- type SlotRange
- type SlowLog
- type SlowLogCmd
- type Sort
- type StatusCmd
- type StringCmd
- type StringSliceCmd
- type StringStructMapCmd
- type Subscription
- type TimeCmd
- type XAddArgs
- type XAutoClaimCmd
- type XAutoClaimJustIDCmd
- type XClaimArgs
- type XInfoConsumer
- type XInfoConsumersCmd
- type XInfoGroup
- type XInfoGroupsCmd
- type XInfoStream
- type XInfoStreamCmd
- type XInfoStreamConsumer
- type XInfoStreamConsumerPending
- type XInfoStreamFull
- type XInfoStreamFullCmd
- type XInfoStreamGroup
- type XInfoStreamGroupPending
- type XMessage
- type XMessageSliceCmd
- type XPending
- type XPendingCmd
- type XPendingExt
- type XPendingExtArgs
- type XPendingExtCmd
- type XReadArgs
- type XReadGroupArgs
- type XStream
- type XStreamSliceCmd
- type Z
- type ZAddArgs
- type ZRangeArgs
- type ZRangeBy
- type ZSliceCmd
- type ZSliceWithKeyCmd
- type ZStore
- type ZWithKey
- type ZWithKeyCmd
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNil 当 Get、GetStruct 等方法期望返回非 nil 值但实际返回 nil 时返回此错误。 ErrNil = redis.Nil // ErrClosed 当对已关闭的客户端执行操作时返回此错误。 ErrClosed = redis.ErrClosed // TxFailedErr 表示 Redis 事务执行失败的错误。 TxFailedErr = redis.TxFailedErr //nolint:errname )
Functions ¶
This section is empty.
Types ¶
type ClusterLinksCmd ¶
type ClusterLinksCmd = redis.ClusterLinksCmd
ClusterLinksCmd 表示返回集群链接信息的 Redis 命令。
type ClusterShardsCmd ¶
type ClusterShardsCmd = redis.ClusterShardsCmd
ClusterShardsCmd 表示返回集群分片信息的 Redis 命令。
type ClusterSlotsCmd ¶
type ClusterSlotsCmd = redis.ClusterSlotsCmd
ClusterSlotsCmd 表示返回集群槽位信息的 Redis 命令。
type CommandsInfoCmd ¶
type CommandsInfoCmd = redis.CommandsInfoCmd
CommandsInfoCmd 表示返回命令信息的 Redis 命令。
type FunctionListCmd ¶
type FunctionListCmd = redis.FunctionListCmd
FunctionListCmd 表示返回函数列表的 Redis 命令。
type FunctionListQuery ¶
type FunctionListQuery = redis.FunctionListQuery
FunctionListQuery 表示函数列表查询参数类型。
type FunctionStatsCmd ¶
type FunctionStatsCmd = redis.FunctionStatsCmd
FunctionStatsCmd 表示返回函数统计信息的 Redis 命令。
type GeoLocationCmd ¶
type GeoLocationCmd = redis.GeoLocationCmd
GeoLocationCmd 表示返回地理位置信息的 Redis 命令。
type GeoSearchLocationCmd ¶
type GeoSearchLocationCmd = redis.GeoSearchLocationCmd
GeoSearchLocationCmd 表示返回地理位置搜索结果的 Redis 命令。
type GeoSearchLocationQuery ¶
type GeoSearchLocationQuery = redis.GeoSearchLocationQuery
GeoSearchLocationQuery 表示地理位置搜索位置查询类型。
type GeoSearchStoreQuery ¶
type GeoSearchStoreQuery = redis.GeoSearchStoreQuery
GeoSearchStoreQuery 表示地理位置搜索存储查询类型。
type KeyValueSliceCmd ¶
type KeyValueSliceCmd = redis.KeyValueSliceCmd
KeyValueSliceCmd 表示返回键值对切片类型的 Redis 命令。
type LCSMatchedPosition ¶
type LCSMatchedPosition = redis.LCSMatchedPosition
LCSMatchedPosition 表示最长公共子序列匹配位置类型。
type MapStringIntCmd ¶
type MapStringIntCmd = redis.MapStringIntCmd
MapStringIntCmd 表示返回字符串到整数映射类型的 Redis 命令。
type MapStringInterfaceCmd ¶
type MapStringInterfaceCmd = redis.MapStringInterfaceCmd
MapStringInterfaceCmd 表示返回字符串到接口映射类型的 Redis 命令。
type MapStringStringCmd ¶
type MapStringStringCmd = redis.MapStringStringSliceCmd
MapStringStringCmd 表示返回字符串到字符串映射类型的 Redis 命令。
type MapStringStringSliceCmd ¶
type MapStringStringSliceCmd = redis.MapStringStringSliceCmd
MapStringStringSliceCmd 表示返回字符串到字符串切片映射类型的 Redis 命令。
type ModuleLoadexConfig ¶
type ModuleLoadexConfig = redis.ModuleLoadexConfig
ModuleLoadexConfig 表示模块加载配置类型。
type Option ¶
type Option func(*redisClient)
Option 定义了 Redis 客户端的配置选项类型。 用于在创建 Redis 客户端时进行自定义配置。
type RankWithScoreCmd ¶
type RankWithScoreCmd = redis.RankWithScoreCmd
RankWithScoreCmd 表示返回带分数的排名的 Redis 命令。
type Redis ¶
type Redis interface {
Scripter
// Do 执行任意 Redis 命令。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - args:命令的参数列表
//
// 返回值:
// - *Cmd:通用的命令结果对象
Do(ctx context.Context, args ...interface{}) *Cmd
// Pipelined 在管道中执行多个命令。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - fn:定义要在管道中执行的命令的函数
//
// 返回值:
// - []Cmder:管道中所有命令的执行结果
// - error:执行过程中的错误信息
Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
// TxPipelined 在事务管道中执行多个命令。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - fn:定义要在事务管道中执行的命令的函数
//
// 返回值:
// - []Cmder:事务中所有命令的执行结果
// - error:执行过程中的错误信息
TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
// Subscribe 订阅指定的频道。
//
// 参数:
// - ctx:上下文对象,用于控制订阅的生命周期
// - channels:要订阅的频道列表
//
// 返回值:
// - *PubSub:发布订阅客户端对象
Subscribe(ctx context.Context, channels ...string) *PubSub
// PSubscribe 使用模式匹配订阅频道。
//
// 参数:
// - ctx:上下文对象,用于控制订阅的生命周期
// - channels:要订阅的频道模式列表
//
// 返回值:
// - *PubSub:发布订阅客户端对象
PSubscribe(ctx context.Context, channels ...string) *PubSub
// Close 关闭 Redis 客户端。
//
// 返回值:
// - error:关闭过程中发生的错误
Close() error
}
Redis 接口定义了 Redis 客户端的基本操作。
type RedisExtension ¶
type RedisExtension interface {
Redis
// Get 获取指定键的值。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - key:要获取的键名
//
// 返回值:
// - *Cmd:命令执行结果
Get(ctx context.Context, key string) *Cmd
// Set 设置指定键的值。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - key:要设置的键名
// - value:要设置的值
// - expiration:键的过期时间
//
// 返回值:
// - *Cmd:命令执行结果
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *Cmd
// Del 删除指定的键。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - key:要删除的键名
//
// 返回值:
// - *Cmd:命令执行结果
Del(ctx context.Context, key string) *Cmd
// Expire 设置指定键的过期时间。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
// - key:要设置过期时间的键名
// - expiration:过期时间
//
// 返回值:
// - *Cmd:命令执行结果
Expire(ctx context.Context, key string, expiration time.Duration) *Cmd
// ScriptFlush 清空脚本缓存。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
//
// 返回值:
// - *StatusCmd:命令执行状态
ScriptFlush(ctx context.Context) *StatusCmd
// ScriptKill 终止当前正在执行的脚本。
//
// 参数:
// - ctx:上下文对象,用于控制命令的执行
//
// 返回值:
// - *StatusCmd:命令执行状态
ScriptKill(ctx context.Context) *StatusCmd
}
RedisExtension 定义了 Redis 扩展接口,继承自基础 Redis 接口,提供额外的功能扩展。
func NewRedisExtension ¶
func NewRedisExtension(redis Redis) RedisExtension
NewRedisExtension 创建一个新的 Redis 扩展实例。
参数:
- redis:基础的 Redis 接口实现
返回值:
- RedisExtension:Redis 扩展接口实例
type StringSliceCmd ¶
type StringSliceCmd = redis.StringSliceCmd
StringSliceCmd 表示返回字符串切片类型的 Redis 命令。
type StringStructMapCmd ¶
type StringStructMapCmd = redis.StringStructMapCmd
StringStructMapCmd 表示返回字符串到结构体映射类型的 Redis 命令。
type XAutoClaimJustIDCmd ¶
type XAutoClaimJustIDCmd = redis.XAutoClaimJustIDCmd
XAutoClaimJustIDCmd 表示仅返回自动认领消息 ID 的 Redis 命令。
type XInfoConsumersCmd ¶
type XInfoConsumersCmd = redis.XInfoConsumersCmd
XInfoConsumersCmd 表示返回消费者信息的 Redis 命令。
type XInfoGroupsCmd ¶
type XInfoGroupsCmd = redis.XInfoGroupsCmd
XInfoGroupsCmd 表示返回消费者组信息的 Redis 命令。
type XInfoStreamCmd ¶
type XInfoStreamCmd = redis.XInfoStreamCmd
XInfoStreamCmd 表示返回 Stream 信息的 Redis 命令。
type XInfoStreamConsumer ¶
type XInfoStreamConsumer = redis.XInfoStreamConsumer
XInfoStreamConsumer 表示 Stream 消费者信息类型。
type XInfoStreamConsumerPending ¶
type XInfoStreamConsumerPending = redis.XInfoStreamConsumerPending
XInfoStreamConsumerPending 表示 Stream 消费者待处理消息信息类型。
type XInfoStreamFull ¶
type XInfoStreamFull = redis.XInfoStreamFull
XInfoStreamFull 表示完整 Stream 信息类型。
type XInfoStreamFullCmd ¶
type XInfoStreamFullCmd = redis.XInfoStreamFullCmd
XInfoStreamFullCmd 表示返回完整 Stream 信息的 Redis 命令。
type XInfoStreamGroup ¶
type XInfoStreamGroup = redis.XInfoStreamGroup
XInfoStreamGroup 表示 Stream 组信息类型。
type XInfoStreamGroupPending ¶
type XInfoStreamGroupPending = redis.XInfoStreamGroupPending
XInfoStreamGroupPending 表示 Stream 组待处理消息信息类型。
type XMessageSliceCmd ¶
type XMessageSliceCmd = redis.XMessageSliceCmd
XMessageSliceCmd 表示返回 Stream 消息切片类型的 Redis 命令。
type XPendingExtArgs ¶
type XPendingExtArgs = redis.XPendingExtArgs
XPendingExtArgs 表示扩展待处理消息查询参数类型。
type XPendingExtCmd ¶
type XPendingExtCmd = redis.XPendingExtCmd
XPendingExtCmd 表示返回扩展待处理消息类型的 Redis 命令。
type XReadGroupArgs ¶
type XReadGroupArgs = redis.XReadGroupArgs
XReadGroupArgs 表示 Stream 消费者组读取消息的参数类型。
type XStreamSliceCmd ¶
type XStreamSliceCmd = redis.XStreamSliceCmd
XStreamSliceCmd 表示返回 Stream 切片类型的 Redis 命令。
type ZSliceWithKeyCmd ¶
type ZSliceWithKeyCmd = redis.ZSliceWithKeyCmd
ZSliceWithKeyCmd 表示返回带键的有序集合切片类型的 Redis 命令。