pool

package
v1.20.123 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: Zlib Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const SlotNumber = 16384

SlotNumber the number of slot

Variables

This section is empty.

Functions

func Key

func Key(key string) string

Key get the key for slot hash

func NewPool

func NewPool(clusterConf []*config.Cluster)

func Slot

func Slot(key string) int

Slot get the slot of key hashSlot returns a consistent slot number between 0 and 16383 for any given string key.

Types

type Client

type Client struct {
	Clusters     []*redis.ClusterClient //集群
	W            int                    //写成功数
	R            int                    //读成功数
	WriteTimeout time.Duration          //总写时延
	ReadTimeout  time.Duration          //总读时延
}

Client 线程池类型

func Get

func Get() *Client

Get 获取线程池

func (*Client) ClusterInfo

func (c *Client) ClusterInfo(ctx context.Context) (string, error)

ClusterInfo 获取集群信息

func (*Client) ClusterNodes

func (c *Client) ClusterNodes(ctx context.Context) (string, error)

ClusterNodes 获取

func (*Client) Del

func (c *Client) Del(ctx context.Context, keys ...string) (int64, error)

Del 删除key

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, key ...string) (int64, error)

Exists 查询key是否存在

func (*Client) Expire

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

Expire 设置过期时间

func (*Client) Forget

func (c *Client) Forget(ctx context.Context, nodeID string) (string, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (string, error)

Get 获取字段

func (*Client) GetSet

func (c *Client) GetSet(ctx context.Context, key string, value interface{}) (string, error)

GetSet 的包装

func (*Client) HDel

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

HDel 批量 Del

func (*Client) HDelWithBatch

func (c *Client) HDelWithBatch(ctx context.Context, reqs []*MHDelreq) (res int64, err error)

HDelWithBatch 批量HDel

func (*Client) HExists

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

HExists 判断field是否存在

func (*Client) HGet

func (c *Client) HGet(ctx context.Context, key, field string) (string, error)

HGet Hash table 查询

func (*Client) HGetAll

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

HGetAll 获取整个Hash table

func (*Client) HIncrBy

func (c *Client) HIncrBy(ctx context.Context, key string, field string, inrc int64) (res int64, err error)

HIncrBy field中的值增加inrc

func (*Client) HIncrByFloat

func (c *Client) HIncrByFloat(ctx context.Context, key string, field string, inrc float64) (res float64, err error)

HIncrByFloat HIncrBy 的float版

func (*Client) HIncrByWithBatch

func (c *Client) HIncrByWithBatch(ctx context.Context, reqs []*MHIncrByReq) (res int64, err error)

HIncrByWithBatch 批量 HIncrBy

func (*Client) HKeys

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

HKeys 获取hash table中的fields

func (*Client) HMGet

func (c *Client) HMGet(ctx context.Context, key string, fields ...string) (map[string]interface{}, error)

HMGet 批量获取Hash table

func (*Client) HMSet

func (c *Client) HMSet(ctx context.Context, key string, fields map[string]interface{}) (bool, error)

HMSet 批量HSet

func (*Client) HMSetWithBatch

func (c *Client) HMSetWithBatch(ctx context.Context, reqs []*HMSetReq) (res string, err error)

HMSetWithBatch 批量HMSet

func (*Client) HSet

func (c *Client) HSet(ctx context.Context, key, field string, value interface{}) (int64, error)

HSet Hash table 插入

func (*Client) HSetNX

func (c *Client) HSetNX(ctx context.Context, key, field string, value interface{}) (bool, error)

HSet Hash table 插入

func (*Client) HSetNXWithBatch

func (c *Client) HSetNXWithBatch(ctx context.Context, keys []string, field string, value interface{}) (bool, error)

HSetWithBatch 批量插入多个key

func (*Client) HSetWithBatch

func (c *Client) HSetWithBatch(ctx context.Context, keys []string, field string, value interface{}) (int64, error)

HSetWithBatch 批量插入多个key

func (*Client) HVals

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

HVals 获取hash vals

func (*Client) Info

func (c *Client) Info(ctx context.Context, section ...string) (res map[string]string, err error)

Info 获取所有就节点信息

func (*Client) Keys

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

Keys 查询是否存在key

func (*Client) LIndex

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

LIndex 返回表中index的值

func (*Client) LInsert

func (c *Client) LInsert(ctx context.Context, key, op string, pivot, value interface{}) (int64, error)

LInsert 将值 value 插入到列表 key 当中,位于值 pivot 之前或之后。

func (*Client) LLen

func (c *Client) LLen(ctx context.Context, key string) (int64, error)

LLen 返回表长度

func (*Client) LPop

func (c *Client) LPop(ctx context.Context, key string) (string, error)

LPop 弹出表头

func (*Client) LPush

func (c *Client) LPush(ctx context.Context, expiration time.Duration, key string, value ...interface{}) (res int64, err error)

LPush 把value 插到表头

func (*Client) LRange

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

LRange 随机返回index 在start和stop 一个value

func (*Client) LSet

func (c *Client) LSet(ctx context.Context, key string, index int64, value interface{}) (string, error)

LSet 设置表中index 的值为 value

func (*Client) LTrim

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

func (*Client) MExpire

func (c *Client) MExpire(ctx context.Context, reqs []*MExpireReq) (bool, error)

MExpire 批量设置过期时间

func (*Client) MGet

func (c *Client) MGet(ctx context.Context, keys ...string) ([]*KeyValue, error)

MGet 批量设置

func (*Client) MHIncrByFloatWithBatch

func (c *Client) MHIncrByFloatWithBatch(ctx context.Context, reqs []*MHIncrByFloatReq) (res float64, err error)

MHIncrByFloatWithBatch HIncrByWithBatch float版

func (*Client) MLInsert

func (c *Client) MLInsert(ctx context.Context, reqs []*MLInsertReq) (res int64, err error)

MLInsert 批量 LInsert

func (*Client) MLLen

func (c *Client) MLLen(ctx context.Context, keys ...string) (map[string]int64, error)

MLLen 返回表长度

func (*Client) MLPop

func (c *Client) MLPop(ctx context.Context, keys ...string) (res string, err error)

MLPop 批量弹出表头

func (*Client) MLPush

func (c *Client) MLPush(ctx context.Context, reqs []*MLPushReq) (res int64, err error)

MLPush 批量 LPush

func (*Client) MLSet

func (c *Client) MLSet(ctx context.Context, reqs []*MLSetReq) (res string, err error)

MLSet 批量 LSet

func (*Client) MRPop

func (c *Client) MRPop(ctx context.Context, keys ...string) (res string, err error)

MRPop 批量弹出表尾

func (*Client) MRPush

func (c *Client) MRPush(ctx context.Context, reqs []*MRPushReq) (res int64, err error)

MRPush 批量 RPush

func (*Client) MSAdd

func (c *Client) MSAdd(ctx context.Context, reqs []*MSAddReq) (int64, error)

MSAdd 批量 SAdd

func (*Client) MSRem

func (c *Client) MSRem(ctx context.Context, reqs []*MSRemReq) (int64, error)

MSRem 批量 SRem

func (*Client) MSet

func (c *Client) MSet(ctx context.Context, req ...*MSetReq) (string, error)

MSet 批量设置

func (*Client) MZAdd

func (c *Client) MZAdd(ctx context.Context, reqs []*MZAddReq) (int64, error)

MZAdd 添加sorted set

func (*Client) MZIncrBy

func (c *Client) MZIncrBy(ctx context.Context, reqs []*MZIncrByReq) (float64, error)

MZIncrBy 批量为有序集 key 的成员 member 的 score 值加上增量 increment

func (*Client) MZRem

func (c *Client) MZRem(ctx context.Context, reqs []*MZRemReq) (int64, error)

MZRem 移除多个序集 key 中的一个或多个成员,不存在的成员将被忽略

func (*Client) MZRemRangeByRank

func (c *Client) MZRemRangeByRank(ctx context.Context, reqs []*MZRemRangeByRankReq) (int64, error)

MZRemRangeByRank 按照排序批量移除多个有序集成员

func (*Client) MZRemRangeByScore

func (c *Client) MZRemRangeByScore(ctx context.Context, reqs []*MZRemRangeByScoreReq) (int64, error)

MZRemRangeByScore 按照score,批量移除多个有序集成员

func (*Client) NodeInfo

func (c *Client) NodeInfo(ctx context.Context, addr string, section ...string) (res string, err error)

NodeInfo 获取单个节点的info

func (*Client) RPop

func (c *Client) RPop(ctx context.Context, key string) (string, error)

RPop 弹出表尾

func (*Client) RPush

func (c *Client) RPush(ctx context.Context, expiration time.Duration, key string, value ...interface{}) (res int64, err error)

RPush 把value 插到表头

func (*Client) SAdd

func (c *Client) SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)

SAdd set中添加 members

func (*Client) SCard

func (c *Client) SCard(ctx context.Context, key string) (int64, error)

SCard 返回set中 key 的基数

func (*Client) SIsMember

func (c *Client) SIsMember(ctx context.Context, key string, member interface{}) (bool, error)

SIsMember 判断member是否为 set中的成员

func (*Client) SMembers

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

SMembers 返回set中的多有成员

func (*Client) SPop

func (c *Client) SPop(ctx context.Context, key string) (string, error)

SPop 随机弹出 set中的成员

func (*Client) SRandMember

func (c *Client) SRandMember(ctx context.Context, key string) (string, error)

SRandMember 随机返回set中一个元素

func (*Client) SRandMemberN

func (c *Client) SRandMemberN(ctx context.Context, key string, n int64) ([]string, error)

SRandMemberN 随机返回set中N个元素

func (*Client) SRem

func (c *Client) SRem(ctx context.Context, key string, member ...interface{}) (int64, error)

SRem 移除集合 key 中的一个或多个 member 元素

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)

Set 对于Set

func (*Client) SetNX

func (c *Client) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)

对于SetNX 的包装

func (*Client) SetNXWithKeys

func (c *Client) SetNXWithKeys(ctx context.Context, keys []string, value interface{}, expiration time.Duration) (bool, error)

Sets 对于Set和SetNX 的包装

func (*Client) SetWithKeys

func (c *Client) SetWithKeys(ctx context.Context, keys []string, value interface{}, expiration time.Duration) (string, error)

func (*Client) TTL

func (c *Client) TTL(ctx context.Context, key string) (time.Duration, error)

TTL 查询TTL

func (*Client) ZAdd

func (c *Client) ZAdd(ctx context.Context, key string, member ...Z) (int64, error)

ZAdd 添加sorted set

func (*Client) ZCard

func (c *Client) ZCard(ctx context.Context, key string) (int64, error)

ZCard 返回有序集 key 的基数。

func (*Client) ZCount

func (c *Client) ZCount(ctx context.Context, key, min, max string) (int64, error)

ZCount 返回score在min, max 中的数量 ,默认闭区间开一在min和max前添加 ( 来使用开区间,min 和 max 可以是 -inf 和 +inf

func (*Client) ZIncrBy

func (c *Client) ZIncrBy(ctx context.Context, key string, increment float64, member string) (float64, error)

ZIncrBy 为有序集 key 的成员 member 的 score 值加上增量 increment

func (*Client) ZRange

func (c *Client) ZRange(ctx context.Context, key string, start, stop int64) ([]string, error)

ZRange 返回有序集 key 中,指定区间内的成员,从小到大, 下标参数 start 和 stop 都以 0 为底,也就是说,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。 你也可以使用负数下标,以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Client) ZRangeByScore

func (c *Client) ZRangeByScore(ctx context.Context, key, min, max string, offset, count int64) ([]string, error)

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

func (*Client) ZRangeByScoreWithScores

func (c *Client) ZRangeByScoreWithScores(ctx context.Context, key, min, max string, offset, count int64) ([]*Z, error)

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

func (*Client) ZRangeWithScores

func (c *Client) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]*Z, error)

ZRangeWithScores 返回有序集 key 中,指定区间内的成员(带score), 从小到大

func (*Client) ZRem

func (c *Client) ZRem(ctx context.Context, key string, members ...interface{}) (int64, error)

ZRem 移除有序集 key 中的一个或多个成员,不存在的成员将被忽略

func (*Client) ZRemRangeByRank

func (c *Client) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) (int64, error)

ZRemRangeByRank 移除有序集 key 中,指定排名(rank)区间内的所有成员

func (*Client) ZRemRangeByScore

func (c *Client) ZRemRangeByScore(ctx context.Context, key string, min, max string) (int64, error)

ZRemRangeByScore 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。

func (*Client) ZRevRange

func (c *Client) ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error)

ZRevRange 返回有序集 key 中,指定区间内的成员,从大到小 下标参数 start 和 stop 都以 0 为底,也就是说,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。 你也可以使用负数下标,以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Client) ZRevRangeByScore

func (c *Client) ZRevRangeByScore(ctx context.Context, key, min, max string, offset, count int64) ([]string, error)

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

func (*Client) ZRevRangeByScoreWithScores

func (c *Client) ZRevRangeByScoreWithScores(ctx context.Context, key, min, max string, offset, count int64) ([]*Z, error)

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

func (*Client) ZRevRangeWithScores

func (c *Client) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]*Z, error)

ZRevRangeWithScores 返回有序集 key 中,指定区间内的成员(带score), 从大到小

func (*Client) ZScore

func (c *Client) ZScore(ctx context.Context, key, member string) (float64, error)

ZScore 返回有序集 key 中,成员 member 的 score 值。

type HMSetReq

type HMSetReq struct {
	Key   string
	Filed map[string]interface{}
}

HMSetReq 批量HMSet参数

type KeyValue

type KeyValue struct {
	Key   string
	Value string
	Err   error
}

KeyValue key-value数对

type MExpireReq

type MExpireReq struct {
	Key        string
	Expiration time.Duration
}

MExpireReq 批量设置过期时间参数

type MHDelreq

type MHDelreq struct {
	Key   string
	Field []string
}

MHDelreq 批量HDel参数

type MHIncrByFloatReq

type MHIncrByFloatReq struct {
	Key   string
	Field string
	Inrc  float64
}

MHIncrByFloatReq MHIncrByReq float版

type MHIncrByReq

type MHIncrByReq struct {
	Key   string
	Field string
	Inrc  int64
}

MHIncrByReq 批量 HIncrBy 参数

type MLInsertReq

type MLInsertReq struct {
	Key   string
	Op    string
	Pivot interface{}
	Value interface{}
}

MLInsertReq 批量 LInsert参数

type MLPushReq

type MLPushReq struct {
	Key        string
	Value      []interface{}
	Expiration time.Duration
}

MLPushReq 批量 LPush 参数

type MLSetReq

type MLSetReq struct {
	Key   string
	Index int64
	Value interface{}
}

MLSetReq 批量 LSet 参数

type MRPushReq

type MRPushReq MLPushReq

type MSAddReq

type MSAddReq struct {
	Key     string
	Members []interface{}
}

MSAddReq 批量 SAdd 参数

type MSRemReq

type MSRemReq struct {
	Key     string
	Members []interface{}
}

MSRemReq 批量 SRem 参数

type MSetReq

type MSetReq struct {
	Key   string
	Value interface{}
}

MSetReq MSets的参数

type MZAddReq

type MZAddReq struct {
	Key     string
	Members []*Z
}

MZAddReq 批量插入有序集 参数

type MZIncrByReq

type MZIncrByReq struct {
	Key       string
	Increment float64
	Member    string
}

MZIncrByReq 批量为有序集 key 的成员 member 的 score 值加上增量 increment 参数

type MZRemRangeByRankReq

type MZRemRangeByRankReq struct {
	Key         string
	Start, Stop int64
}

MZRemRangeByRankReq 按照排序批量移除多个有序集成员的参数

type MZRemRangeByScoreReq

type MZRemRangeByScoreReq struct {
	Key      string
	Min, Max string
}

MZRemRangeByScoreReq 按照score,批量移除多个有序集成员参数,

type MZRemReq

type MZRemReq struct {
	Key     string
	Members []interface{}
}

MZRemReq 批量移除有序集参数

type Z

type Z struct {
	Score  float64
	Member interface{}
}

Z sorted set Strut

Jump to

Keyboard shortcuts

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