Documentation ¶
Overview ¶
Package redis defined redis_client
Package redis defined redis_client
Package redis defined redis_client
Package redis defined redis_client
Package redis defined redis_client
Index ¶
- Variables
- func ByteSlices(reply interface{}, err error) ([][]byte, error)
- func Bytes(reply interface{}, err error) ([]byte, error)
- func Int(reply interface{}, err error) (int, error)
- func Int64(reply interface{}, err error) (int64, error)
- func Ints(reply interface{}, err error) ([]int, error)
- func String(reply interface{}, err error) (string, error)
- func Strings(reply interface{}, err error) ([]string, error)
- func Values(reply interface{}, err error) ([]interface{}, error)
- type AcquireConnMode
- type Conn
- type Error
- type Manager
- func (m *Manager) BLPop(ctx context.Context, key string, secTimeout int64) (interface{}, error)
- func (m *Manager) BRPop(ctx context.Context, key string, secTimeout int64) (interface{}, error)
- func (m *Manager) Decr(ctx context.Context, key string) (reply interface{}, err error)
- func (m *Manager) DecrBy(ctx context.Context, key string, delt int) (reply interface{}, err error)
- func (m *Manager) Del(ctx context.Context, key string) (interface{}, error)
- func (m *Manager) Exists(ctx context.Context, key string) (bool, error)
- func (m *Manager) Expire(ctx context.Context, key string, ttl int64) (interface{}, error)
- func (m *Manager) Get(ctx context.Context, key string) (reply interface{}, err error)
- func (m *Manager) GetString(ctx context.Context, key string) (reply string, err error)
- func (m *Manager) HDel(ctx context.Context, key, sub string) (interface{}, error)
- func (m *Manager) HExists(ctx context.Context, key, sub string) (bool, error)
- func (m *Manager) HGet(ctx context.Context, key, sub string) (reply interface{}, err error)
- func (m *Manager) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (m *Manager) HIncrBy(ctx context.Context, key, sub string, delt int) (reply interface{}, err error)
- func (m *Manager) HKeys(ctx context.Context, key string) ([]string, error)
- func (m *Manager) HLen(ctx context.Context, key string) (int, error)
- func (m *Manager) HMGet(ctx context.Context, key string, subKeys []string) (map[string]string, error)
- func (m *Manager) HMSet(ctx context.Context, key string, subKV map[string]interface{}) (interface{}, error)
- func (m *Manager) HSet(ctx context.Context, key, sub string, val interface{}) (reply interface{}, err error)
- func (m *Manager) Incr(ctx context.Context, key string) (reply interface{}, err error)
- func (m *Manager) IncrBy(ctx context.Context, key string, delt int) (reply interface{}, err error)
- func (m *Manager) LLen(ctx context.Context, key string) (int, error)
- func (m *Manager) LPop(ctx context.Context, key string) (interface{}, error)
- func (m *Manager) LPush(ctx context.Context, key string, val interface{}) (interface{}, error)
- func (m *Manager) LRange(ctx context.Context, key string, start, end int) ([]interface{}, error)
- func (m *Manager) LRem(ctx context.Context, key string, count int, val interface{}) (int64, error)
- func (m *Manager) MGet(ctx context.Context, keys []string) (map[string]string, error)
- func (m *Manager) MSet(ctx context.Context, kv map[string]interface{}) (reply interface{}, err error)
- func (m *Manager) MockBlock(dur time.Duration)
- func (m *Manager) RPop(ctx context.Context, key string) (interface{}, error)
- func (m *Manager) RPush(ctx context.Context, key string, val interface{}) (interface{}, error)
- func (m *Manager) SAdd(ctx context.Context, key string, member interface{}) (interface{}, error)
- func (m *Manager) SCard(ctx context.Context, key string) (int, error)
- func (m *Manager) SIsMember(ctx context.Context, key string, member interface{}) (bool, error)
- func (m *Manager) SMembers(ctx context.Context, key string) ([]interface{}, error)
- func (m *Manager) SRem(ctx context.Context, key string, member interface{}) (interface{}, error)
- func (m *Manager) SUnion(ctx context.Context, sets []string) ([]interface{}, error)
- func (m *Manager) Set(ctx context.Context, key string, val interface{}) (reply interface{}, err error)
- func (m *Manager) SetEx(ctx context.Context, key string, expireTime int, val interface{}) (reply interface{}, err error)
- func (m *Manager) SetNEx(ctx context.Context, key string, expireTime int, val interface{}) (reply interface{}, err error)
- func (m *Manager) ZAdd(ctx context.Context, key string, score float64, member interface{}) (interface{}, error)
- func (m *Manager) ZRangeByScore(ctx context.Context, key string, min, max float64) (interface{}, error)
- func (m *Manager) ZRemRangeByScore(ctx context.Context, key string, min, max float64) (interface{}, error)
- type ManagerMap
- type ManagerMapConfig
- type Option
- func DisfServiceName(sn string) Option
- func EnableDisf() Option
- func EnableNodemgr() Option
- func Prefix(prefix string) Option
- func SetAcquireConnMode(mode AcquireConnMode) Option
- func SetClusterName(cn string) Option
- func SetConnectTimeout(cTimeout time.Duration) Option
- func SetDB(db int) Option
- func SetHealthyThreshold(threshold int64) Option
- func SetKeepSilent(silent bool) Option
- func SetMaxConn(max int64) Option
- func SetMaxCooldownTime(time int64) Option
- func SetMinHealthyRatio(ratio float64) Option
- func SetPoolSize(poolSize int64) Option
- func SetReadTimeout(rTimeout time.Duration) Option
- func SetSLAFuse(enable bool) Option
- func SetStatFunc(...) Option
- func SetWaitTimeout(wtTimeout time.Duration) Option
- func SetWorkerCycle(cycle int) Option
- func SetWriteTimeout(wTimeout time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyConnPool empty connection pool ErrEmptyConnPool = errors.New("empty connection pool") // ErrAcquiredConnTimeout acquire connection timed out ErrAcquiredConnTimeout = errors.New("acquire connection timed out") // ErrNilValue redis nil value ErrNilValue = redis.ErrNil // ErrNoManagerAvailable 表示在全局的 manager map 中找不到该 Manager 的注册记录 ErrNoManagerAvailable = errors.New("no available manager in manager map, check your cluster name?") // ErrSLATimeout 已经超时直接熔断redis操作 ErrSLATimeout = errors.New("sla timeout, interrupted redis action") )
Functions ¶
func ByteSlices ¶
ByteSlices wrapper
Types ¶
type AcquireConnMode ¶
type AcquireConnMode uint8
AcquireConnMode ...
const ( // AcquireConnModeUnblock ... AcquireConnModeUnblock AcquireConnMode = iota // AcquireConnModeTimeout ... AcquireConnModeTimeout // AcquireConnModeBlock ... AcquireConnModeBlock )
type Manager ¶
type Manager struct { Connected int // 初始化新建的可用连接数 // contains filtered or unexported fields }
Manager redis client
func NewManager ¶
NewManager ...
func NewManagerFromConfig ¶
NewManagerFromConfig ...
func (*Manager) HIncrBy ¶
func (m *Manager) HIncrBy(ctx context.Context, key, sub string, delt int) (reply interface{}, err error)
HIncrBy command
func (*Manager) HMGet ¶
func (m *Manager) HMGet(ctx context.Context, key string, subKeys []string) (map[string]string, error)
HMGet command
func (*Manager) HMSet ¶
func (m *Manager) HMSet(ctx context.Context, key string, subKV map[string]interface{}) (interface{}, error)
HMSet command
func (*Manager) HSet ¶
func (m *Manager) HSet(ctx context.Context, key, sub string, val interface{}) (reply interface{}, err error)
HSet command
func (*Manager) MSet ¶
func (m *Manager) MSet(ctx context.Context, kv map[string]interface{}) (reply interface{}, err error)
MSet command
func (*Manager) Set ¶
func (m *Manager) Set(ctx context.Context, key string, val interface{}) (reply interface{}, err error)
Set command
func (*Manager) SetEx ¶
func (m *Manager) SetEx(ctx context.Context, key string, expireTime int, val interface{}) (reply interface{}, err error)
SetEx command
func (*Manager) SetNEx ¶
func (m *Manager) SetNEx(ctx context.Context, key string, expireTime int, val interface{}) (reply interface{}, err error)
SetNEx setNX与Expire的合并 需要redis版本大于2.6.12
func (*Manager) ZAdd ¶
func (m *Manager) ZAdd(ctx context.Context, key string, score float64, member interface{}) (interface{}, error)
ZAdd command
type ManagerMap ¶
type ManagerMap struct {
// contains filtered or unexported fields
}
ManagerMap 存储一组 Manager,按照
func NewManagerMap ¶
func NewManagerMap(clusterConfigArr []ManagerMapConfig) (*ManagerMap, error)
NewManagerMap 返回一组 codis cluster 按照名字获取对应的 Manager
func (*ManagerMap) GetManager ¶
func (mm *ManagerMap) GetManager(clusterName string) (*Manager, error)
GetManager 根据 codis 的 cluster name 获取对应的 Manager
type ManagerMapConfig ¶
ManagerMapConfig 对应一个 codis 集群(几个对等的ip)
type Option ¶
type Option func(o *option)
Option 动态参数配置,使 NewManger 支持变参,不设定的参数使用默认值
func SetAcquireConnMode ¶
func SetAcquireConnMode(mode AcquireConnMode) Option
SetAcquireConnMode 设置获取连接模式:阻塞、超时等待、直接返回
func SetConnectTimeout ¶
SetConnectTimeout 连接超时
func SetHealthyThreshold ¶
SetHealthyThreshold 设置nodemgr 健康节点投票阈值
func SetMaxCooldownTime ¶
SetMaxCooldownTime 设置nodemgr 故障恢复时间
func SetMinHealthyRatio ¶
SetMinHealthyRatio 设置nodemgr 最小可用度保护
func SetPoolSize ¶
SetPoolSize 设置初始连接池大小 叫 initial pool size 更合适
func SetStatFunc ¶
func SetStatFunc(sFunc func(ctx context.Context, cmd string, cost time.Duration, err error) error) Option
SetStatFunc 是统计命令字符串、时延、redis操作错误的闭包
func SetWaitTimeout ¶
SetWaitTimeout 等待连接池中的连接的超时