redis类

package
v0.0.0-...-7e18bce Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

包gredis提供了对Redis服务器的便捷客户端。

Redis客户端。

Redis命令官方文档:https://redis.io/commands

Redis中文文档:http://redisdoc.com/ md5:fd856764d3114fd3

Index

Constants

View Source
const (
	DefaultGroupName = "default" // 默认配置组名称。 md5:eb4945d78061d92a
)

Variables

This section is empty.

Functions

func ClearConfig

func ClearConfig()

ClearConfig 删除所有的 Redis 配置。 md5:337bf67372d51962

func RegisterAdapterFunc

func RegisterAdapterFunc(adapterFunc AdapterFunc)

RegisterAdapterFunc 注册创建默认 Redis 适配器的函数。 md5:2390765dfc7002cb

func RemoveConfig

func RemoveConfig(name ...string)

RemoveConfig 删除指定组的全局配置。 如果没有传递 `name`,则删除默认组名的配置。 md5:8e808827f299122d

func SetConfig

func SetConfig(config *Config, name ...string)

SetConfig 为指定的组设置全局配置。 如果没有传递 `name`,则为默认组名设置配置。 md5:8d7c1f181c0057f0

func SetConfigByMap

func SetConfigByMap(m map[string]interface{}, name ...string) error

SetConfigByMap 使用映射设置指定组的全局配置。 如果未传递`name`,则将配置设置为默认组名。 md5:1d191bb426ab05fb

Types

type Adapter

type Adapter interface {
	AdapterGroup
	AdapterOperation
}

Adapter是通用Redis操作的接口。 md5:9c96b73f93ac5323

type AdapterFunc

type AdapterFunc func(config *Config) Adapter

AdapterFunc 是创建 Redis 适配器的函数。 md5:806d31217d679afd

type AdapterGroup

type AdapterGroup interface {
	GroupGeneric() IGroupGeneric
	GroupHash() IGroupHash
	GroupList() IGroupList
	GroupPubSub() IGroupPubSub
	GroupScript() IGroupScript
	GroupSet() IGroupSet
	GroupSortedSet() IGroupSortedSet
	GroupString() IGroupString
}

AdapterGroup 是一个接口,用于管理 Redis 的组操作。 md5:f603a1b02c295995

type AdapterOperation

type AdapterOperation interface {
	// 发送一个命令到服务器并返回接收到的回复。
	// 在将结构体/切片/映射类型的值提交到redis之前,它使用json.Marshal进行编码。
	// md5:5a464ca35e177113
	Do(ctx context.Context, command string, args ...interface{}) (*gvar.Var, error)

	// Conn 获取并返回一个用于连续操作的连接对象。
	// 请注意,如果您不再使用此连接,请手动调用 Close 函数。
	// md5:adf083088afcd372
	Conn(ctx context.Context) (conn Conn, err error)

	// Close 方法关闭当前Redis客户端,关闭其连接池并释放所有相关资源。 md5:bfd91d0269572038
	Close(ctx context.Context) (err error)
}

AdapterOperation 是 Redis 的核心操作函数。 这些函数可以被自定义实现轻松覆盖。 md5:6a3c39d3c764e39e

type Config

type Config struct {
	// Address 支持单个和集群 Redis 服务器。多个地址使用逗号分隔。例如:192.168.1.1:6379, 192.168.1.2:6379。 md5:21ac53e24210b32c
	Address         string        `json:"address"`
	Db              int           `json:"db"`              // Redis db.
	User            string        `json:"user"`            // Username for AUTH.
	Pass            string        `json:"pass"`            // Password for AUTH.
	SentinelUser    string        `json:"sentinel_user"`   // 防卫者AUTH的用户名。 md5:c85c5044b04f7ec3
	SentinelPass    string        `json:"sentinel_pass"`   // 密码,用于sentinel的AUTH。 md5:517cbd39fc9e4f20
	MinIdle         int           `json:"minIdle"`         // 允许处于空闲状态的连接的最小数量(默认为0). md5:534a8e485a7c5664
	MaxIdle         int           `json:"maxIdle"`         // 允许的最大空闲连接数(默认为10). md5:6b33b39ddbb7c42b
	MaxActive       int           `json:"maxActive"`       // 连接数的最大限制(默认为0表示无限制)。 md5:4dbd7ce4d80b4597
	MaxConnLifetime time.Duration `json:"maxConnLifetime"` // 连接的最大生命周期(默认为30秒,不允许设置为0). md5:1650bf54f8065411
	IdleTimeout     time.Duration `json:"idleTimeout"`     // 连接的最大空闲时间(默认为10秒,不允许设置为0). md5:1f9346d51eb9e76a
	WaitTimeout     time.Duration `json:"waitTimeout"`     // 超时等待从连接池获取连接的持续时间。 md5:ff75b0772da43843
	DialTimeout     time.Duration `json:"dialTimeout"`     // TCP连接的超时时间。 md5:d900304d9b7c2e58
	ReadTimeout     time.Duration `json:"readTimeout"`     // TCP读超时。如果没有必要,请不要设置它。 md5:44e33a5ef46ceb97
	WriteTimeout    time.Duration `json:"writeTimeout"`    // Write timeout for TCP.
	MasterName      string        `json:"masterName"`      // 用于Redis哨兵模式。 md5:44b4d0f3813a15e6
	TLS             bool          `json:"tls"`             // 指定连接到服务器时是否应使用TLS。 md5:0b36620d5b0321dd
	TLSSkipVerify   bool          `json:"tlsSkipVerify"`   // 连接TLS时禁用服务器名称验证。 md5:3bde87f1295352e9
	TLSConfig       *tls.Config   `json:"-"`               // 使用的TLS配置。如果设置,将协商TLS。 md5:b5a9a25bb2762b0b
	SlaveOnly       bool          `json:"slaveOnly"`       // 将所有命令路由到从属只读节点。 md5:9ba156f404a631f1
	Cluster         bool          `json:"cluster"`         // 指定是否使用集群模式。 md5:7952648d7b1da3f9
	Protocol        int           `json:"protocol"`        // 定义RESP版本(协议2或3)。 md5:dbc1edfd3b1e3b35
}

Config 是 Redis 配置。 md5:5409b3144db1576a

func ConfigFromMap

func ConfigFromMap(m map[string]interface{}) (config *Config, err error)

ConfigFromMap 从给定的映射中解析并返回配置。 md5:105a2224aed53bc9

func GetConfig

func GetConfig(name ...string) (config *Config, ok bool)

GetConfig 返回指定组名的全局配置。如果未传入 `name`,则返回默认组名的配置。 md5:327a839e91668442

type Conn

type Conn interface {
	ConnCommand

	// 发送一个命令到服务器并返回接收到的回复。
	// 在将结构体/切片/映射类型的值提交到redis之前,它使用json.Marshal进行编码。
	// md5:5a464ca35e177113
	Do(ctx context.Context, command string, args ...interface{}) (result *gvar.Var, err error)

	// Close 将连接放回连接池。 md5:7cc2158c987fb9c1
	Close(ctx context.Context) (err error)
}

Conn 是一个通用 Redis 客户端连接的接口。 md5:75bf8588ab4ad4e1

type ConnCommand

type ConnCommand interface {
	// Subscribe 将客户端订阅到指定的频道。
	// 参考链接:https:	//redis.io/commands/subscribe/
	// md5:a7414ed1d330bfc7
	Subscribe(ctx context.Context, channel string, channels ...string) ([]*Subscription, error)

	// PSubscribe 将客户端订阅给定的模式。
	//
	// 支持的glob风格模式:
	// - h?llo 订阅hello, hallo和hxllo
	// - h*llo 订阅hllo和heeeello
	// - h[ae]llo 订阅hello和hallo,但不订阅hillo
	//
	// 如果需要匹配特殊字符本身,请使用\进行转义。
	//
	// https:	//redis.io/commands/psubscribe/
	// md5:0bfeb7ebd0d003a7
	PSubscribe(ctx context.Context, pattern string, patterns ...string) ([]*Subscription, error)

	// ReceiveMessage 从Redis服务器接收一个订阅的消息。 md5:dbf6509713a7b2b3
	ReceiveMessage(ctx context.Context) (*Message, error)

	// Receive 从Redis服务器接收一个作为gvar.Var的单个回复。 md5:c4dad7138865cef4
	Receive(ctx context.Context) (result *gvar.Var, err error)
}

ConnCommand是一个接口,用于管理与特定连接绑定的一些操作。 md5:25fa514417ce2230

type CopyOption

type CopyOption struct {
	DB      int  // DB 选项允许为目的地键指定一个替代的逻辑数据库索引。 md5:f7752ecd2c09888e
	REPLACE bool // REPLACE选项在将值复制到目标键之前删除目标键。 md5:7d1daa6e1cf324ab
}

CopyOption 为 Copy 函数提供选项。 md5:985df0dc4c62e896

type ExpireOption

type ExpireOption struct {
	NX bool // NX -- 只在键没有过期时设置过期时间. md5:753349361957bc17
	XX bool // XX -- 只在键已存在过期时间时设置过期. md5:005a0b6114104985
	GT bool // GT -- 仅当新过期时间大于当前过期时间时,才设置过期时间. md5:e25f0e8a00a61ecf
	LT bool // LT -- 只有当新的过期时间小于当前过期时间时才设置过期时间. md5:7d837833fbcaa3f3
}

ExpireOption 提供了 Expire 函数的选项。 md5:fe605b48792fd395

type FlushOp

type FlushOp string
const (
	FlushAsync FlushOp = "ASYNC" // ASYNC:异步刷新数据库. md5:8f0fb503842c62dc
	FlushSync  FlushOp = "SYNC"  // 同步:同步刷新数据库. md5:c995019017769085
)

type GetEXOption

type GetEXOption struct {
	TTLOption
	Persist bool // Persist -- 删除与键关联的过期时间。 md5:68ca7740bd8bdb7c
}

GetEXOption 为 GetEx 函数提供额外选项。 md5:853b343734200902

type IGroupGeneric

type IGroupGeneric interface {
	Copy(ctx context.Context, source, destination string, option ...CopyOption) (int64, error)
	Exists(ctx context.Context, keys ...string) (int64, error)
	Type(ctx context.Context, key string) (string, error)
	Unlink(ctx context.Context, keys ...string) (int64, error)
	Rename(ctx context.Context, key, newKey string) error
	RenameNX(ctx context.Context, key, newKey string) (int64, error)
	Move(ctx context.Context, key string, db int) (int64, error)
	Del(ctx context.Context, keys ...string) (int64, error)
	RandomKey(ctx context.Context) (string, error)
	DBSize(ctx context.Context) (int64, error)
	Keys(ctx context.Context, pattern string) ([]string, error)
	Scan(ctx context.Context, cursor uint64, option ...ScanOption) (uint64, []string, error)
	FlushDB(ctx context.Context, option ...FlushOp) error
	FlushAll(ctx context.Context, option ...FlushOp) error
	Expire(ctx context.Context, key string, seconds int64, option ...ExpireOption) (int64, error)
	ExpireAt(ctx context.Context, key string, time time.Time, option ...ExpireOption) (int64, error)
	ExpireTime(ctx context.Context, key string) (*gvar.Var, error)
	TTL(ctx context.Context, key string) (int64, error)
	Persist(ctx context.Context, key string) (int64, error)
	PExpire(ctx context.Context, key string, milliseconds int64, option ...ExpireOption) (int64, error)
	PExpireAt(ctx context.Context, key string, time time.Time, option ...ExpireOption) (int64, error)
	PExpireTime(ctx context.Context, key string) (*gvar.Var, error)
	PTTL(ctx context.Context, key string) (int64, error)
}

IGroupGeneric 管理通用的 Redis 操作。 实现了 redis.GroupGeneric 接口。 md5:d6eb4921760b60f4

type IGroupHash

type IGroupHash interface {
	HSet(ctx context.Context, key string, fields map[string]interface{}) (int64, error)
	HSetNX(ctx context.Context, key, field string, value interface{}) (int64, error)
	HGet(ctx context.Context, key, field string) (*gvar.Var, error)
	HStrLen(ctx context.Context, key, field string) (int64, error)
	HExists(ctx context.Context, key, field string) (int64, error)
	HDel(ctx context.Context, key string, fields ...string) (int64, error)
	HLen(ctx context.Context, key string) (int64, error)
	HIncrBy(ctx context.Context, key, field string, increment int64) (int64, error)
	HIncrByFloat(ctx context.Context, key, field string, increment float64) (float64, error)
	HMSet(ctx context.Context, key string, fields map[string]interface{}) error
	HMGet(ctx context.Context, key string, fields ...string) (gvar.Vars, error)
	HKeys(ctx context.Context, key string) ([]string, error)
	HVals(ctx context.Context, key string) (gvar.Vars, error)
	HGetAll(ctx context.Context, key string) (*gvar.Var, error)
}

IGroupHash 管理Redis哈希操作。 实现参见 redis.GroupHash。 md5:25da2b7d81c6ce3b

type IGroupList

type IGroupList interface {
	LPush(ctx context.Context, key string, values ...interface{}) (int64, error)
	LPushX(ctx context.Context, key string, element interface{}, elements ...interface{}) (int64, error)
	RPush(ctx context.Context, key string, values ...interface{}) (int64, error)
	RPushX(ctx context.Context, key string, value interface{}) (int64, error)
	LPop(ctx context.Context, key string, count ...int) (*gvar.Var, error)
	RPop(ctx context.Context, key string, count ...int) (*gvar.Var, error)
	LRem(ctx context.Context, key string, count int64, value interface{}) (int64, error)
	LLen(ctx context.Context, key string) (int64, error)
	LIndex(ctx context.Context, key string, index int64) (*gvar.Var, error)
	LInsert(ctx context.Context, key string, op LInsertOp, pivot, value interface{}) (int64, error)
	LSet(ctx context.Context, key string, index int64, value interface{}) (*gvar.Var, error)
	LRange(ctx context.Context, key string, start, stop int64) (gvar.Vars, error)
	LTrim(ctx context.Context, key string, start, stop int64) error
	BLPop(ctx context.Context, timeout int64, keys ...string) (gvar.Vars, error)
	BRPop(ctx context.Context, timeout int64, keys ...string) (gvar.Vars, error)
	RPopLPush(ctx context.Context, source, destination string) (*gvar.Var, error)
	BRPopLPush(ctx context.Context, source, destination string, timeout int64) (*gvar.Var, error)
}

IGroupList 管理Redis列表操作。 实现了redis.GroupList接口。 md5:25ae44de5ae09921

type IGroupPubSub

type IGroupPubSub interface {
	Publish(ctx context.Context, channel string, message interface{}) (int64, error)
	Subscribe(ctx context.Context, channel string, channels ...string) (Conn, []*Subscription, error)
	PSubscribe(ctx context.Context, pattern string, patterns ...string) (Conn, []*Subscription, error)
}

IGroupPubSub 管理 redis 的发布/订阅操作。 实现了 redis.GroupPubSub 接口。 md5:9987807bf281dfb2

type IGroupScript

type IGroupScript interface {
	Eval(ctx context.Context, script string, numKeys int64, keys []string, args []interface{}) (*gvar.Var, error)
	EvalSha(ctx context.Context, sha1 string, numKeys int64, keys []string, args []interface{}) (*gvar.Var, error)
	ScriptLoad(ctx context.Context, script string) (string, error)
	ScriptExists(ctx context.Context, sha1 string, sha1s ...string) (map[string]bool, error)
	ScriptFlush(ctx context.Context, option ...ScriptFlushOption) error
	ScriptKill(ctx context.Context) error
}

IGroupScript 管理 redis 脚本操作。 实现了 redis.GroupScript 接口。 md5:e1fe409124b24bad

type IGroupSet

type IGroupSet interface {
	SAdd(ctx context.Context, key string, member interface{}, members ...interface{}) (int64, error)
	SIsMember(ctx context.Context, key string, member interface{}) (int64, error)
	SPop(ctx context.Context, key string, count ...int) (*gvar.Var, error)
	SRandMember(ctx context.Context, key string, count ...int) (*gvar.Var, error)
	SRem(ctx context.Context, key string, member interface{}, members ...interface{}) (int64, error)
	SMove(ctx context.Context, source, destination string, member interface{}) (int64, error)
	SCard(ctx context.Context, key string) (int64, error)
	SMembers(ctx context.Context, key string) (gvar.Vars, error)
	SMIsMember(ctx context.Context, key, member interface{}, members ...interface{}) ([]int, error)
	SInter(ctx context.Context, key string, keys ...string) (gvar.Vars, error)
	SInterStore(ctx context.Context, destination string, key string, keys ...string) (int64, error)
	SUnion(ctx context.Context, key string, keys ...string) (gvar.Vars, error)
	SUnionStore(ctx context.Context, destination, key string, keys ...string) (int64, error)
	SDiff(ctx context.Context, key string, keys ...string) (gvar.Vars, error)
	SDiffStore(ctx context.Context, destination string, key string, keys ...string) (int64, error)
}

IGroupSet 管理 Redis 集合操作。 实现了 redis.GroupSet 接口。 md5:98fdccab09106c8c

type IGroupSortedSet

type IGroupSortedSet interface {
	ZAdd(ctx context.Context, key string, option *ZAddOption, member ZAddMember, members ...ZAddMember) (*gvar.Var, error)
	ZScore(ctx context.Context, key string, member interface{}) (float64, error)
	ZIncrBy(ctx context.Context, key string, increment float64, member interface{}) (float64, error)
	ZCard(ctx context.Context, key string) (int64, error)
	ZCount(ctx context.Context, key string, min, max string) (int64, error)
	ZRange(ctx context.Context, key string, start, stop int64, option ...ZRangeOption) (gvar.Vars, error)
	ZRevRange(ctx context.Context, key string, start, stop int64, option ...ZRevRangeOption) (*gvar.Var, error)
	ZRank(ctx context.Context, key string, member interface{}) (int64, error)
	ZRevRank(ctx context.Context, key string, member interface{}) (int64, error)
	ZRem(ctx context.Context, key string, member interface{}, members ...interface{}) (int64, error)
	ZRemRangeByRank(ctx context.Context, key string, start, stop int64) (int64, error)
	ZRemRangeByScore(ctx context.Context, key string, min, max string) (int64, error)
	ZRemRangeByLex(ctx context.Context, key string, min, max string) (int64, error)
	ZLexCount(ctx context.Context, key, min, max string) (int64, error)
}

IGroupSortedSet 管理 redis 排序集合操作。 实现了 redis.GroupSortedSet。 md5:85c86f571889c1f2

type IGroupString

type IGroupString interface {
	X设置值(ctx context.Context, key string, value interface{}, option ...SetOption) (*gvar.Var, error)
	SetNX(ctx context.Context, key string, value interface{}) (bool, error)
	SetEX(ctx context.Context, key string, value interface{}, ttlInSeconds int64) error
	Get(ctx context.Context, key string) (*gvar.Var, error)
	GetDel(ctx context.Context, key string) (*gvar.Var, error)
	GetEX(ctx context.Context, key string, option ...GetEXOption) (*gvar.Var, error)
	GetSet(ctx context.Context, key string, value interface{}) (*gvar.Var, error)
	StrLen(ctx context.Context, key string) (int64, error)
	Append(ctx context.Context, key string, value string) (int64, error)
	SetRange(ctx context.Context, key string, offset int64, value string) (int64, error)
	GetRange(ctx context.Context, key string, start, end int64) (string, error)
	Incr(ctx context.Context, key string) (int64, error)
	IncrBy(ctx context.Context, key string, increment int64) (int64, error)
	IncrByFloat(ctx context.Context, key string, increment float64) (float64, error)
	Decr(ctx context.Context, key string) (int64, error)
	DecrBy(ctx context.Context, key string, decrement int64) (int64, error)
	MSet(ctx context.Context, keyValueMap map[string]interface{}) error
	MSetNX(ctx context.Context, keyValueMap map[string]interface{}) (bool, error)
	MGet(ctx context.Context, keys ...string) (map[string]*gvar.Var, error)
}

IGroupString 管理 Redis 字符串操作。 实现了 redis.GroupString。 md5:1b6f861ea35b113e

type LInsertOp

type LInsertOp string

LInsertOp 定义了 LInsert 函数的操作名称。 md5:c91fe5287aa13a21

const (
	LInsertBefore LInsertOp = "BEFORE"
	LInsertAfter  LInsertOp = "AFTER"
)

type Message

type Message struct {
	Channel      string
	Pattern      string
	Payload      string
	PayloadSlice []string
}

作为另一客户端发出PUBLISH命令的结果接收到的消息。 md5:1b54d1f2ea66a492

type Redis

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

Redis client.

func Instance

func Instance(name ...string) *Redis

Instance 返回指定分组的 redis 客户端实例。 如果未传入 `name` 参数,它将返回一个使用默认配置分组的 redis 实例。 md5:22f72aaad455f11e

func New

func New(config ...*Config) (*Redis, error)

New 创建并返回一个redis客户端。 它创建了一个默认的go-redis适配器。 md5:3f355ab0e775862a

func NewWithAdapter

func NewWithAdapter(adapter Adapter) (*Redis, error)

NewWithAdapter 使用给定的适配器创建并返回一个Redis客户端。 md5:ab7dc6695935087f

func (*Redis) Close

func (r *Redis) Close(ctx context.Context) error

Close 方法关闭当前Redis客户端,关闭其连接池并释放所有相关资源。 md5:bfd91d0269572038

func (*Redis) Conn

func (r *Redis) Conn(ctx context.Context) (Conn, error)

Conn 获取并返回一个用于连续操作的连接对象。 请注意,如果您不再使用此连接,请手动调用 Close 函数。 md5:b0379f4ab8131447

func (*Redis) Do

func (r *Redis) Do(ctx context.Context, command string, args ...interface{}) (*gvar.Var, error)

Do 向服务器发送命令并返回接收到的回复。 它在将结构体、切片或映射类型值提交到Redis之前,使用json.Marshal进行序列化。 md5:bbe59d4e1ff07fa3

func (*Redis) GetAdapter

func (r *Redis) GetAdapter() Adapter

GetAdapter 返回当前 Redis 客户端设置的适配器。 md5:c46228b935b43204

func (*Redis) MustConn

func (r *Redis) MustConn(ctx context.Context) Conn

MustConn 表现如同 Conn 函数,但是如果内部发生任何错误,它将引发 panic。 md5:555eb0f8f348b94c

func (*Redis) MustDo

func (r *Redis) MustDo(ctx context.Context, command string, args ...interface{}) *gvar.Var

MustDo 执行与 Do 相同的操作,但如果内部出现任何错误,它将引发 panic。 md5:0d30101f0e9e6a4e

func (*Redis) SetAdapter

func (r *Redis) SetAdapter(adapter Adapter)

SetAdapter 将当前 Redis 客户端的底层适配器替换为自定义适配器。 md5:f503f97750dcd95a

type ScanOption

type ScanOption struct {
	Match string // Match - 定义用于筛选键的通配符风格模式。 md5:8a1fe0030e22d0f9
	Count int    // Count -- 建议每次扫描返回的键的数量。 md5:9090884e4078ad30
	Type  string // Type -- 根据键的数据类型过滤。有效的类型包括 "string"、"list"、"set"、"zset"、"hash" 和 "stream"。 md5:e1661eb01e6db304
}

ScanOption为Scan函数提供了选项。 md5:32efa528c8a65e49

func (*ScanOption) ToUsedOption

func (scanOpt *ScanOption) ToUsedOption() doScanOption

ToUsedOption 将ScanOption中的零值字段转换为nil。只有具有值的字段才会被保留。 md5:42a6307a3e94db33

type ScriptFlushOption

type ScriptFlushOption struct {
	SYNC  bool // SYNC 将缓存同步刷新。 md5:199c25e221e4fff0
	ASYNC bool // ASYNC 异步刷新缓存。 md5:cc79b38230559523
}

ScriptFlushOption 是 ScriptFlush 函数的选项。 md5:dc79d8420cb1e3bb

type SetOption

type SetOption struct {
	TTLOption
	NX bool // 只有在键不存在时才设置它。 md5:29aba97b33955575
	XX bool // 仅当键已存在时才设置该键。 md5:919ca2b47e92656f

	// 返回key存储的旧字符串,如果key不存在则返回nil。
	// 如果key存储的值不是字符串,将返回错误并中止SET操作。
	// md5:0932521a97426d54
	Get bool
}

SetOption为Set函数提供额外选项。 md5:c920a4cbd42cf35d

type Subscription

type Subscription struct {
	Kind    string // 可以是 "subscribe"、"unsubscribe"、"psubscribe" 或 "punsubscribe"。 md5:1344d1b60899d10a
	Channel string // 我们已订阅的频道名称。 md5:aed766d24e08c59a
	Count   int    // 我们当前订阅的频道数量。 md5:3af00e20830c4421
}

成功订阅频道后接收到的订阅信息。 md5:18e121df658bbde2

func (*Subscription) String

func (m *Subscription) String() string

String 将当前对象转换为可读的字符串。 md5:b831e7b38fabfe56

type TTLOption

type TTLOption struct {
	EX      *int64 // EX seconds -- 设置指定的过期时间,以秒为单位。 md5:c9b922a2aed5b01f
	PX      *int64 // PX 毫秒 - 设置指定的过期时间,以毫秒为单位。 md5:7355e125322e02a7
	EXAT    *int64 // EXAT 时间戳-秒 - 设置键将在多少秒后过期的指定Unix时间。 md5:e9439dac9f4a9efa
	PXAT    *int64 // PXAT 时间戳-毫秒 -- 设置键将在指定的Unix时间(以毫秒为单位)过期。 md5:0342540fbf12c73c
	KeepTTL bool   // 保留与键相关联的生存时间。 md5:b504515edfac8f85
}

TTLOption 为与TTL(生存时间)相关的功能提供额外的选项。 md5:806d2a9bb0ba8e2c

type ZAddMember

type ZAddMember struct {
	Score  float64
	Member interface{}
}

ZAddMember 是集合(set)中的元素结构体。 md5:eb7d172c444324d7

type ZAddOption

type ZAddOption struct {
	XX bool // Only update elements that already exist. Don't add new elements.
	NX bool // Only add new elements. Don't update already existing elements.
	// 只有当新分数小于当前分数时,才更新已存在的元素。
	// 此标志不会阻止添加新元素。
	// md5:df3556a5d410e3c9
	LT bool

	// 只有当新分数大于当前分数时,才更新现有元素。此标志不会阻止添加新元素。
	// md5:4866b5e44d3c1bec
	GT bool

	// 将返回值从新添加元素的数量修改为更改的总元素数量(CH代表已更改)。
	// 已更改的元素包括新添加的元素和分数已被更新的现有元素。
	// 因此,命令行中指定的与过去相同的分数的元素不计入总数。
	// 注意:通常情况下,ZAdd的返回值只计算新添加的元素数量。
	// md5:f80865660e63c42c
	CH bool

	// 当指定了此选项时,ZAdd 命令的行为类似于 ZIncrBy。在这种模式下,只能指定一个分数-元素对。 md5:bb002fb3eec4eb13
	INCR bool
}

ZAddOption 为 ZAdd 函数提供选项。 md5:b3e234b14d4a1ca8

type ZRangeOption

type ZRangeOption struct {
	ByScore bool
	ByLex   bool
	// 可选的REV参数会反转顺序,因此元素按照分数从高到低排序,分数相同时则通过反向字典序进行解析。
	// md5:a1c79d75cedbff1b
	Rev   bool
	Limit *ZRangeOptionLimit
	// 可选的 WithScores 参数会在命令回复中补充返回元素的分数。 md5:26db0341550d511b
	WithScores bool
}

ZRangeOption为ZRange函数提供额外选项。 md5:61532d16fe5a1260

type ZRangeOptionLimit

type ZRangeOptionLimit struct {
	Offset *int
	Count  *int
}

ZRangeOptionLimit 为 ZRange 函数提供 LIMIT 参数。 可选的 LIMIT 参数可用于从匹配的元素中获取子范围(类似于 SQL 中的 SELECT LIMIT 偏移量, 数量)。当 `Count` 为负数时,从 `Offset` 开始返回所有元素。 md5:a910bb82b51914ef

type ZRevRangeOption

type ZRevRangeOption struct {
	WithScores bool
}

ZRevRangeOption为ZRevRange函数提供了选项。 md5:cd0b627793d48f50

Jump to

Keyboard shortcuts

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