redis

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 3 Imported by: 0

README

redis

简介

redis 包提供了 Go 语言下的高性能 Redis 客户端接口与扩展,支持原生命令、管道、事务、Lua 脚本、发布订阅、基础 KV 操作等,兼容 go-redis v9,适合缓存、分布式锁、消息队列等多种场景。

主要特性
  • 统一 Redis 客户端接口,支持 Do/Pipelined/TxPipelined/Subscribe/PSubscribe
  • 支持扩展接口(Get/Set/Del/Expire 等常用命令)
  • 支持 Lua 脚本(Eval/EvalSha/ScriptLoad/ScriptExists 等)
  • 支持发布订阅(PubSub)
  • 支持 Option 配置(地址、密码等)
  • 完善的错误处理与类型封装
  • 完整单元测试覆盖
设计理念

redis 包遵循"简洁、兼容、易扩展"的设计理念,接口与 go-redis v9 保持一致,支持 Option 配置,便于集成与二次封装。扩展接口覆盖常用场景,底层类型与命令高度兼容官方客户端。

安装

前置条件
  • Go 版本要求:Go 1.18+
  • 依赖要求:
    • github.com/redis/go-redis/v9
    • github.com/stretchr/testify(仅测试)
安装命令
go get -u github.com/fsyyft-go/kit/database/redis

快速开始

基础用法
package main

import (
    "context"
    "fmt"
    "github.com/fsyyft-go/kit/database/redis"
    "time"
)

func main() {
    // 创建 Redis 客户端,默认 127.0.0.1:6379
    rdb := redis.NewRedis()
    ext := redis.NewRedisExtension(rdb)
    ctx := context.Background()
    // 基础 KV 操作
    ext.Set(ctx, "foo", "bar", time.Second*10)
    val, err := ext.Get(ctx, "foo").Result()
    if err != nil {
        panic(err)
    }
    fmt.Println("foo:", val)
}
管道与事务
// 管道批量操作
_, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
    pipe.Do(ctx, "SET", "k1", "v1")
    pipe.Do(ctx, "SET", "k2", "v2")
    return nil
})

// 事务管道
_, err := rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
    pipe.Do(ctx, "INCR", "counter")
    return nil
})
Lua 脚本
script := `return ARGV[1]`
sha, _ := rdb.ScriptLoad(ctx, script).Result()
res, _ := rdb.EvalSha(ctx, sha, []string{}, 123).Result()
fmt.Println(res)
发布订阅
pubsub := rdb.Subscribe(ctx, "my-channel")
go func() {
    msg, _ := pubsub.ReceiveMessage(ctx)
    fmt.Println("收到消息:", msg.Payload)
}()
rdb.Do(ctx, "PUBLISH", "my-channel", "hello")

详细指南

核心概念
  • Redis 接口:统一封装 go-redis v9,支持所有原生命令
  • 扩展接口:常用 KV 操作、过期、删除等
  • 管道/事务:批量高效操作,事务保证原子性
  • Lua 脚本:支持 Eval/EvalSha/ScriptLoad/ScriptExists
  • 发布订阅:支持多频道订阅与消息收发
  • Option 配置:灵活设置地址、密码等参数
常见用例
  • 缓存读写
  • 分布式锁
  • 计数器/排行榜
  • 消息队列/事件通知
  • 脚本原子操作
最佳实践
  • 生产环境建议配置密码与连接池参数
  • 管道/事务适合批量高并发场景
  • 脚本操作建议预加载并用 SHA 调用
  • 发布订阅需注意消息可靠性
  • 始终检查命令返回的 error

API 文档

主要类型
// Redis 客户端接口
 type Redis interface {
    Do(ctx context.Context, args ...interface{}) *Cmd
    Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
    TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
    Subscribe(ctx context.Context, channels ...string) *PubSub
    PSubscribe(ctx context.Context, channels ...string) *PubSub
}

// Redis 扩展接口
 type RedisExtension interface {
    Redis
    Get(ctx context.Context, key string) *Cmd
    Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *Cmd
    Del(ctx context.Context, key string) *Cmd
    Expire(ctx context.Context, key string, expiration time.Duration) *Cmd
}

// Option 配置项类型
 type Option func(*redisClient)

// NewRedis 创建客户端
func NewRedis(opts ...Option) Redis

// NewRedisExtension 创建扩展
func NewRedisExtension(redis Redis) RedisExtension
关键函数
  • NewRedis:创建 Redis 客户端,支持 Option 配置
  • Do:执行任意命令
  • Pipelined/TxPipelined:管道/事务批量操作
  • Subscribe/PSubscribe:发布订阅
  • Eval/EvalSha/ScriptLoad/ScriptExists:Lua 脚本
  • Get/Set/Del/Expire:常用 KV 操作
配置选项
  • WithAddr(addr string):设置 Redis 地址
  • WithPassword(password string):设置密码

错误处理

  • 所有命令均返回 *Cmd,需调用 Result() 获取结果与错误
  • 不存在 key 时返回 redis.ErrNil
  • 连接失败、参数错误等均有详细错误
  • Option 多次叠加后者生效

性能指标

  • 单连接 QPS 万级,管道/批量操作可进一步提升
  • 脚本/事务操作性能取决于 Redis 服务端

测试覆盖率

  • 单元测试覆盖所有接口、边界、异常场景
  • 使用 testify,覆盖率 100%

调试指南

  • 检查 Redis 服务是否可用(默认 127.0.0.1:6379)
  • Option 配置可多次叠加,后者生效
  • 脚本调试建议先用 Eval 验证

相关文档

贡献指南

欢迎提交 Issue、PR 或建议,详见 贡献指南

许可证

本项目采用 MIT License 许可证。详见 LICENSE

Documentation

Overview

Package redis 提供对 go-redis/v9 客户端的轻量封装与常用扩展接口。

NewRedis 创建基于 go-redis/v9 的客户端,并复用底层命令结果类型;返回的 Redis 实例持有底层连接资源, 调用方在不再使用时应调用 Close 释放连接。

RedisExtension 在基础接口上补充常用 KV 与过期操作;ScriptFlush 和 ScriptKill 会按底层实现暴露的能力分派, 当通过 NewRedisExtension 包装的底层实现未提供对应方法时返回 nil,调用方需要显式处理。

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNil 表示 Redis 命令返回 nil 结果。
	//
	// 该错误是 go-redis/v9 的 redis.Nil 别名,常见于 GET 等命令访问不存在的键。
	// 调用方可以使用 errors.Is 与 ErrNil 或 redis.Nil 判断该场景。
	ErrNil = redis.Nil

	// ErrClosed 表示对已关闭的 Redis 客户端执行操作。
	//
	// 该错误是 go-redis/v9 的 redis.ErrClosed 别名,调用方可以据此区分连接生命周期错误。
	ErrClosed = redis.ErrClosed

	// TxFailedErr 表示 Redis 事务监视条件不满足导致事务执行失败。
	//
	// 该错误是 go-redis/v9 的 redis.TxFailedErr 别名,通常由 WATCH 相关事务在提交阶段返回。
	TxFailedErr = redis.TxFailedErr //nolint:errname
)

Functions

This section is empty.

Types

type ACLLogCmd

type ACLLogCmd = redis.ACLLogCmd

ACLLogCmd 表示返回 ACL 日志的 Redis 命令。

type ACLLogEntry

type ACLLogEntry = redis.ACLLogEntry

ACLLogEntry 表示 ACL 日志条目类型。

type BitCount

type BitCount = redis.BitCount

BitCount 表示位计数参数类型。

type BoolCmd

type BoolCmd = redis.BoolCmd

BoolCmd 表示返回布尔类型的 Redis 命令。

type BoolSliceCmd

type BoolSliceCmd = redis.BoolSliceCmd

BoolSliceCmd 表示返回布尔切片类型的 Redis 命令。

type ClientFlags

type ClientFlags = redis.ClientFlags

ClientFlags 表示客户端标志类型。

type ClientInfo

type ClientInfo = redis.ClientInfo

ClientInfo 表示客户端信息类型。

type ClientInfoCmd

type ClientInfoCmd = redis.ClientInfoCmd

ClientInfoCmd 表示返回客户端信息的 Redis 命令。

type ClusterLink = redis.ClusterLink

ClusterLink 表示集群链接类型。

type ClusterLinksCmd

type ClusterLinksCmd = redis.ClusterLinksCmd

ClusterLinksCmd 表示返回集群链接信息的 Redis 命令。

type ClusterNode

type ClusterNode = redis.ClusterNode

ClusterNode 表示集群节点信息类型。

type ClusterShard

type ClusterShard = redis.ClusterShard

ClusterShard 表示集群分片类型。

type ClusterShardsCmd

type ClusterShardsCmd = redis.ClusterShardsCmd

ClusterShardsCmd 表示返回集群分片信息的 Redis 命令。

type ClusterSlot

type ClusterSlot = redis.ClusterSlot

ClusterSlot 表示集群槽位信息类型。

type ClusterSlotsCmd

type ClusterSlotsCmd = redis.ClusterSlotsCmd

ClusterSlotsCmd 表示返回集群槽位信息的 Redis 命令。

type Cmd

type Cmd = redis.Cmd

Cmd 表示通用的 Redis 命令。

type Cmder

type Cmder = redis.Cmder

Cmder 表示 Redis 命令的基础接口。

type CommandInfo

type CommandInfo = redis.CommandInfo

CommandInfo 表示命令信息类型。

type CommandsInfoCmd

type CommandsInfoCmd = redis.CommandsInfoCmd

CommandsInfoCmd 表示返回命令信息的 Redis 命令。

type DurationCmd

type DurationCmd = redis.DurationCmd

DurationCmd 表示返回时间间隔类型的 Redis 命令。

type Engine

type Engine = redis.Engine

Engine 表示脚本引擎类型。

type FilterBy

type FilterBy = redis.FilterBy

FilterBy 表示过滤条件类型。

type FloatCmd

type FloatCmd = redis.FloatCmd

FloatCmd 表示返回浮点数类型的 Redis 命令。

type FloatSliceCmd

type FloatSliceCmd = redis.FloatSliceCmd

FloatSliceCmd 表示返回浮点数切片类型的 Redis 命令。

type Function

type Function = redis.Function

Function 表示 Redis 函数类型。

type FunctionListCmd

type FunctionListCmd = redis.FunctionListCmd

FunctionListCmd 表示返回函数列表的 Redis 命令。

type FunctionListQuery

type FunctionListQuery = redis.FunctionListQuery

FunctionListQuery 表示函数列表查询参数类型。

type FunctionStats

type FunctionStats = redis.FunctionStats

FunctionStats 表示函数统计信息类型。

type FunctionStatsCmd

type FunctionStatsCmd = redis.FunctionStatsCmd

FunctionStatsCmd 表示返回函数统计信息的 Redis 命令。

type GeoLocation

type GeoLocation = redis.GeoLocation

GeoLocation 表示地理位置信息类型。

type GeoLocationCmd

type GeoLocationCmd = redis.GeoLocationCmd

GeoLocationCmd 表示返回地理位置信息的 Redis 命令。

type GeoPos

type GeoPos = redis.GeoPos

GeoPos 表示地理位置坐标类型。

type GeoPosCmd

type GeoPosCmd = redis.GeoPosCmd

GeoPosCmd 表示返回地理位置坐标的 Redis 命令。

type GeoRadiusQuery

type GeoRadiusQuery = redis.GeoRadiusQuery

GeoRadiusQuery 表示地理位置半径查询类型。

type GeoSearchLocationCmd

type GeoSearchLocationCmd = redis.GeoSearchLocationCmd

GeoSearchLocationCmd 表示返回地理位置搜索结果的 Redis 命令。

type GeoSearchLocationQuery

type GeoSearchLocationQuery = redis.GeoSearchLocationQuery

GeoSearchLocationQuery 表示地理位置搜索位置查询类型。

type GeoSearchQuery

type GeoSearchQuery = redis.GeoSearchQuery

GeoSearchQuery 表示地理位置搜索查询类型。

type GeoSearchStoreQuery

type GeoSearchStoreQuery = redis.GeoSearchStoreQuery

GeoSearchStoreQuery 表示地理位置搜索存储查询类型。

type IntCmd

type IntCmd = redis.IntCmd

IntCmd 表示返回整数类型的 Redis 命令。

type IntSliceCmd

type IntSliceCmd = redis.IntSliceCmd

IntSliceCmd 表示返回整数切片类型的 Redis 命令。

type KeyFlags

type KeyFlags = redis.KeyFlags

KeyFlags 表示键标志类型。

type KeyFlagsCmd

type KeyFlagsCmd = redis.KeyFlagsCmd

KeyFlagsCmd 表示返回键标志的 Redis 命令。

type KeyValue

type KeyValue = redis.KeyValue

KeyValue 表示键值对类型。

type KeyValueSliceCmd

type KeyValueSliceCmd = redis.KeyValueSliceCmd

KeyValueSliceCmd 表示返回键值对切片类型的 Redis 命令。

type KeyValuesCmd

type KeyValuesCmd = redis.KeyValuesCmd

KeyValuesCmd 表示返回键值对类型的 Redis 命令。

type LCSCmd

type LCSCmd = redis.LCSCmd

LCSCmd 表示返回最长公共子序列的 Redis 命令。

type LCSMatch

type LCSMatch = redis.LCSMatch

LCSMatch 表示最长公共子序列匹配类型。

type LCSMatchedPosition

type LCSMatchedPosition = redis.LCSMatchedPosition

LCSMatchedPosition 表示最长公共子序列匹配位置类型。

type LCSPosition

type LCSPosition = redis.LCSPosition

LCSPosition 表示最长公共子序列位置类型。

type LCSQuery

type LCSQuery = redis.LCSQuery

LCSQuery 表示最长公共子序列查询类型。

type LPosArgs

type LPosArgs = redis.LPosArgs

LPosArgs 表示列表位置查询参数类型。

type Library

type Library = redis.Library

Library 表示 Redis 库类型。

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 Message

type Message = redis.Message

Message 表示消息类型。

type ModuleLoadexConfig

type ModuleLoadexConfig = redis.ModuleLoadexConfig

ModuleLoadexConfig 表示模块加载配置类型。

type Node

type Node = redis.Node

Node 表示节点类型。

type Option

type Option func(*redisClient)

Option 定义 NewRedis 的函数式配置项。

参数:

  • *redisClient: 待修改的 Redis 客户端配置实例,调用方不应直接传入 nil。

func WithAddr

func WithAddr(addr string) Option

WithAddr 设置 Redis 服务器地址。

参数:

  • addr: Redis 服务器地址,格式通常为 "host:port"。

返回:

  • Option: 应用于 NewRedis 的地址配置项。

func WithPassword

func WithPassword(password string) Option

WithPassword 设置 Redis 服务器认证密码。

参数:

  • password: Redis 服务器认证密码;为空字符串表示不发送密码。

返回:

  • Option: 应用于 NewRedis 的密码配置项。

type Pipeliner

type Pipeliner = redis.Pipeliner

Pipeliner 表示 Redis 管道操作接口。

type Pong

type Pong = redis.Pong

Pong 表示 PING 命令响应类型。

type PubSub

type PubSub = redis.PubSub

PubSub 表示发布订阅客户端类型。

type RankScore

type RankScore = redis.RankScore

RankScore 表示排名分数类型。

type RankWithScoreCmd

type RankWithScoreCmd = redis.RankWithScoreCmd

RankWithScoreCmd 表示返回带分数的排名的 Redis 命令。

type Redis

type Redis interface {
	Scripter

	// Do 执行任意 Redis 命令。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//   - args: 命令名称及其参数,按 Redis 协议顺序传递。
	//
	// 返回:
	//   - *Cmd: 通用命令结果;执行错误由返回值的 Err 方法承载。
	Do(ctx context.Context, args ...interface{}) *Cmd

	// Pipelined 在管道中执行多个命令。
	//
	// 参数:
	//   - ctx: 控制管道执行生命周期的上下文。
	//   - fn: 向管道追加命令的回调;返回错误会中止管道执行。
	//
	// 返回:
	//   - []Cmder: 管道内各命令的执行结果,顺序与追加顺序一致;调用方仍应检查各 Cmder.Err。
	//   - error: fn 返回错误、上下文取消、网络异常或管道执行失败时返回错误。
	Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

	// TxPipelined 在 Redis 事务管道中执行多个命令。
	//
	// 参数:
	//   - ctx: 控制事务管道执行生命周期的上下文。
	//   - fn: 向事务管道追加命令的回调;返回错误会中止事务管道执行。
	//
	// 返回:
	//   - []Cmder: 事务管道内各命令的执行结果,顺序与追加顺序一致;调用方仍应检查各 Cmder.Err。
	//   - error: fn 返回错误、上下文取消、网络异常或事务管道执行失败时返回错误。
	TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

	// Subscribe 订阅一个或多个 Redis 频道。
	//
	// 参数:
	//   - ctx: 控制订阅创建过程的上下文。
	//   - channels: 要订阅的频道名称列表。
	//
	// 返回:
	//   - *PubSub: 发布订阅客户端;调用方在不再接收消息时应关闭该客户端。
	Subscribe(ctx context.Context, channels ...string) *PubSub

	// PSubscribe 按模式订阅一个或多个 Redis 频道。
	//
	// 参数:
	//   - ctx: 控制订阅创建过程的上下文。
	//   - channels: 要订阅的频道模式列表。
	//
	// 返回:
	//   - *PubSub: 发布订阅客户端;调用方在不再接收消息时应关闭该客户端。
	PSubscribe(ctx context.Context, channels ...string) *PubSub

	// Close 关闭 Redis 客户端并释放底层连接资源。
	//
	// 参数:无。
	//
	// 返回:
	//   - error: 底层 go-redis 客户端关闭失败时返回错误。
	Close() error
}

Redis 定义本包暴露的 Redis 客户端基础能力。

Redis 复用 go-redis/v9 的命令结果类型,单命令执行错误通常保存在返回的 Cmd 对象中; 管道和事务管道还会通过返回的 error 承载回调、上下文或执行错误,调用方仍应检查各 Cmder.Err。Redis 实例持有底层连接资源,不再使用时应调用 Close。

func NewRedis

func NewRedis(opts ...Option) Redis

NewRedis 创建一个 Redis 客户端。

未传入选项时,NewRedis 使用包内默认地址和默认密码创建 go-redis/v9 客户端。返回实例持有底层连接资源, 调用方在不再使用时应调用 Close。

参数:

  • opts: 可选配置项,按传入顺序应用;后传入的同类配置会覆盖先前配置。

返回:

  • Redis: 初始化完成的 Redis 客户端接口。

type RedisExtension

type RedisExtension interface {
	Redis

	// Get 获取指定键的值。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//   - key: 要读取的 Redis 键名。
	//
	// 返回:
	//   - *Cmd: GET 命令结果;键不存在时 Err 通常为 ErrNil。
	Get(ctx context.Context, key string) *Cmd

	// Set 设置指定键的值和可选过期时间。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//   - key: 要写入的 Redis 键名。
	//   - value: 要写入的值,编码规则由底层 go-redis 客户端决定。
	//   - expiration: 键过期时间;非正值表示不设置过期时间,整秒使用 EX,非整秒向上取整为毫秒并使用 PX。
	//
	// 返回:
	//   - *Cmd: SET 命令结果;执行错误由返回值的 Err 方法承载。
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *Cmd

	// Del 删除指定键。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//   - key: 要删除的 Redis 键名。
	//
	// 返回:
	//   - *Cmd: DEL 命令结果;执行错误由返回值的 Err 方法承载。
	Del(ctx context.Context, key string) *Cmd

	// Expire 设置指定键的过期时间。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//   - key: 要设置过期语义的 Redis 键名。
	//   - expiration: 键过期时间;正整秒使用 EXPIRE,正非整秒向上取整为毫秒并使用 PEXPIRE,非正值使用 EXPIRE 0。
	//
	// 返回:
	//   - *Cmd: 过期命令结果;执行错误由返回值的 Err 方法承载。
	Expire(ctx context.Context, key string, expiration time.Duration) *Cmd

	// ScriptFlush 按底层客户端能力清空脚本缓存。
	//
	// 当底层 Redis 实现提供 ScriptFlush(context.Context) *StatusCmd 时委托调用;否则返回 nil,调用方应处理 nil 返回值。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//
	// 返回:
	//   - *StatusCmd: 底层支持脚本缓存管理时返回对应命令;否则返回 nil。
	ScriptFlush(ctx context.Context) *StatusCmd

	// ScriptKill 按底层客户端能力终止当前正在执行的脚本。
	//
	// 当底层 Redis 实现提供 ScriptKill(context.Context) *StatusCmd 时委托调用;否则返回 nil,调用方应处理 nil 返回值。
	//
	// 参数:
	//   - ctx: 控制命令执行生命周期的上下文。
	//
	// 返回:
	//   - *StatusCmd: 底层支持脚本终止能力时返回对应命令;否则返回 nil。
	ScriptKill(ctx context.Context) *StatusCmd
}

RedisExtension 定义在 Redis 基础能力之上的常用扩展操作。

RedisExtension 通过 Do 组合 GET、SET、DEL 和过期命令,并保留 Redis 的脚本、管道和订阅能力。 扩展方法返回的命令对象遵循 go-redis/v9 约定,执行错误由命令结果的 Err 方法承载。

func NewRedisExtension

func NewRedisExtension(redis Redis) RedisExtension

NewRedisExtension 创建一个 Redis 扩展实例。

参数:

  • redis: 被包装的基础 Redis 实现;调用方应传入非 nil 实例。

返回:

  • RedisExtension: 基于 redis 转发基础命令并补充常用 KV 操作的扩展实例。

type RunningScript

type RunningScript = redis.RunningScript

RunningScript 表示运行中的脚本类型。

type ScanCmd

type ScanCmd = redis.ScanCmd

ScanCmd 表示扫描操作的 Redis 命令。

type Scripter

type Scripter = redis.Scripter

Scripter 表示 Redis 脚本操作接口。

type SetArgs

type SetArgs = redis.SetArgs

SetArgs 表示设置命令的参数类型。

type SliceCmd

type SliceCmd = redis.SliceCmd

SliceCmd 表示返回切片类型的 Redis 命令。

type SlotRange

type SlotRange = redis.SlotRange

SlotRange 表示槽位范围类型。

type SlowLog

type SlowLog = redis.SlowLog

SlowLog 表示慢查询日志类型。

type SlowLogCmd

type SlowLogCmd = redis.SlowLogCmd

SlowLogCmd 表示返回慢查询日志的 Redis 命令。

type Sort

type Sort = redis.Sort

Sort 表示排序参数类型。

type StatusCmd

type StatusCmd = redis.StatusCmd

StatusCmd 表示返回状态类型的 Redis 命令。

type StringCmd

type StringCmd = redis.StringCmd

StringCmd 表示返回字符串类型的 Redis 命令。

type StringSliceCmd

type StringSliceCmd = redis.StringSliceCmd

StringSliceCmd 表示返回字符串切片类型的 Redis 命令。

type StringStructMapCmd

type StringStructMapCmd = redis.StringStructMapCmd

StringStructMapCmd 表示返回字符串到结构体映射类型的 Redis 命令。

type Subscription

type Subscription = redis.Subscription

Subscription 表示订阅信息类型。

type TimeCmd

type TimeCmd = redis.TimeCmd

TimeCmd 表示返回时间类型的 Redis 命令。

type XAddArgs

type XAddArgs = redis.XAddArgs

XAddArgs 表示 Stream 添加消息的参数类型。

type XAutoClaimCmd

type XAutoClaimCmd = redis.XAutoClaimCmd

XAutoClaimCmd 表示自动认领消息的 Redis 命令。

type XAutoClaimJustIDCmd

type XAutoClaimJustIDCmd = redis.XAutoClaimJustIDCmd

XAutoClaimJustIDCmd 表示仅返回自动认领消息 ID 的 Redis 命令。

type XClaimArgs

type XClaimArgs = redis.XClaimArgs

XClaimArgs 表示消息认领参数类型。

type XInfoConsumer

type XInfoConsumer = redis.XInfoConsumer

XInfoConsumer 表示消费者信息类型。

type XInfoConsumersCmd

type XInfoConsumersCmd = redis.XInfoConsumersCmd

XInfoConsumersCmd 表示返回消费者信息的 Redis 命令。

type XInfoGroup

type XInfoGroup = redis.XInfoGroup

XInfoGroup 表示消费者组信息类型。

type XInfoGroupsCmd

type XInfoGroupsCmd = redis.XInfoGroupsCmd

XInfoGroupsCmd 表示返回消费者组信息的 Redis 命令。

type XInfoStream

type XInfoStream = redis.XInfoStream

XInfoStream 表示 Stream 信息类型。

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 XMessage

type XMessage = redis.XMessage

XMessage 表示 Redis Stream 消息类型。

type XMessageSliceCmd

type XMessageSliceCmd = redis.XMessageSliceCmd

XMessageSliceCmd 表示返回 Stream 消息切片类型的 Redis 命令。

type XPending

type XPending = redis.XPending

XPending 表示待处理消息类型。

type XPendingCmd

type XPendingCmd = redis.XPendingCmd

XPendingCmd 表示返回待处理消息类型的 Redis 命令。

type XPendingExt

type XPendingExt = redis.XPendingExt

XPendingExt 表示扩展的待处理消息类型。

type XPendingExtArgs

type XPendingExtArgs = redis.XPendingExtArgs

XPendingExtArgs 表示扩展待处理消息查询参数类型。

type XPendingExtCmd

type XPendingExtCmd = redis.XPendingExtCmd

XPendingExtCmd 表示返回扩展待处理消息类型的 Redis 命令。

type XReadArgs

type XReadArgs = redis.XReadArgs

XReadArgs 表示 Stream 读取消息的参数类型。

type XReadGroupArgs

type XReadGroupArgs = redis.XReadGroupArgs

XReadGroupArgs 表示 Stream 消费者组读取消息的参数类型。

type XStream

type XStream = redis.XStream

XStream 表示 Redis Stream 类型。

type XStreamSliceCmd

type XStreamSliceCmd = redis.XStreamSliceCmd

XStreamSliceCmd 表示返回 Stream 切片类型的 Redis 命令。

type Z

type Z = redis.Z

Z 表示有序集合元素类型。

type ZAddArgs

type ZAddArgs = redis.ZAddArgs

ZAddArgs 表示有序集合添加元素的参数类型。

type ZRangeArgs

type ZRangeArgs = redis.ZRangeArgs

ZRangeArgs 表示有序集合范围查询参数类型。

type ZRangeBy

type ZRangeBy = redis.ZRangeBy

ZRangeBy 表示有序集合范围查询参数类型。

type ZSliceCmd

type ZSliceCmd = redis.ZSliceCmd

ZSliceCmd 表示返回有序集合切片类型的 Redis 命令。

type ZSliceWithKeyCmd

type ZSliceWithKeyCmd = redis.ZSliceWithKeyCmd

ZSliceWithKeyCmd 表示返回带键的有序集合切片类型的 Redis 命令。

type ZStore

type ZStore = redis.ZStore

ZStore 表示有序集合存储参数类型。

type ZWithKey

type ZWithKey = redis.ZWithKey

ZWithKey 表示带键的有序集合元素类型。

type ZWithKeyCmd

type ZWithKeyCmd = redis.ZWithKeyCmd

ZWithKeyCmd 表示返回带键的有序集合类型的 Redis 命令。

Jump to

Keyboard shortcuts

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