Documentation
¶
Index ¶
- type Client
- func (c *Client) AddSet(ctx context.Context, key string, values ...interface{}) error
- func (c *Client) AddZSet(ctx context.Context, key string, members ...*ZSetMember) error
- func (c *Client) CardZSet(ctx context.Context, key string) (int64, error)
- func (c *Client) CheckSetMember(ctx context.Context, key string, value interface{}) (bool, error)
- func (c *Client) Del(ctx context.Context, key ...string) error
- func (c *Client) FlushDB(ctx context.Context, isAll bool) error
- func (c *Client) GetExpire(ctx context.Context, key string) (time.Duration, error)
- func (c *Client) GetHashField(ctx context.Context, key, field string) (string, error)
- func (c *Client) GetMixed(ctx context.Context, key string, value interface{}) error
- func (c *Client) IsExist(ctx context.Context, key ...string) bool
- func (c *Client) LenList(ctx context.Context, key string) (int64, error)
- func (c *Client) MembersWithScoreZSet(ctx context.Context, key string) ([]*ZSetMember, error)
- func (c *Client) PopList(ctx context.Context, key string, value interface{}) error
- func (c *Client) Publish(ctx context.Context, key string, value interface{}) error
- func (c *Client) PushList(ctx context.Context, key string, values ...interface{}) error
- func (c *Client) RemMembersZSet(ctx context.Context, key string, members ...string) error
- func (c *Client) RemSetEle(ctx context.Context, key string, values ...interface{}) error
- func (c *Client) ScanKey(ctx context.Context, match string) chan string
- func (c *Client) SetExpire(ctx context.Context, key string, ttl time.Duration) error
- func (c *Client) SetHash(ctx context.Context, key string, value map[string]interface{}) error
- func (c *Client) SetNX(ctx context.Context, key, value string, ttl time.Duration) error
- func (c *Client) SetStr(ctx context.Context, key, value string) error
- func (c *Client) SetStrTTL(ctx context.Context, key, value string, ttl time.Duration) error
- func (c *Client) Subscribe(ctx context.Context, channels ...string) (<-chan *Message, error)
- type Cluster
- func (c *Cluster) AddSet(ctx context.Context, key string, values ...interface{}) error
- func (c *Cluster) AddZSet(ctx context.Context, key string, members ...*ZSetMember) error
- func (c *Cluster) CardZSet(ctx context.Context, key string) (int64, error)
- func (c *Cluster) CheckSetMember(ctx context.Context, key string, value interface{}) (bool, error)
- func (c *Cluster) Del(ctx context.Context, key ...string) error
- func (c *Cluster) FlushDB(ctx context.Context, isAll bool) error
- func (c *Cluster) GetExpire(ctx context.Context, key string) (time.Duration, error)
- func (c *Cluster) GetHashField(ctx context.Context, key, field string) (string, error)
- func (c *Cluster) GetMixed(ctx context.Context, key string, value interface{}) error
- func (c *Cluster) IsExist(ctx context.Context, key ...string) bool
- func (c *Cluster) LenList(ctx context.Context, key string) (int64, error)
- func (c *Cluster) MembersWithScoreZSet(ctx context.Context, key string) ([]*ZSetMember, error)
- func (c *Cluster) PopList(ctx context.Context, key string, value interface{}) error
- func (c *Cluster) Publish(ctx context.Context, key string, value interface{}) error
- func (c *Cluster) PushList(ctx context.Context, key string, values ...interface{}) error
- func (c *Cluster) RemMembersZSet(ctx context.Context, key string, members ...string) error
- func (c *Cluster) RemSetEle(ctx context.Context, key string, values ...interface{}) error
- func (c *Cluster) ScanKey(ctx context.Context, match string) chan string
- func (c *Cluster) SetExpire(ctx context.Context, key string, ttl time.Duration) error
- func (c *Cluster) SetHash(ctx context.Context, key string, value map[string]interface{}) error
- func (c *Cluster) SetNX(ctx context.Context, key, value string, ttl time.Duration) error
- func (c *Cluster) SetStr(ctx context.Context, key, value string) error
- func (c *Cluster) SetStrTTL(ctx context.Context, key, value string, ttl time.Duration) error
- func (c *Cluster) Subscribe(ctx context.Context, channels ...string) (<-chan *Message, error)
- type DeployMode
- type ListFlag
- type Message
- type OptionFunc
- type OptionFuncForCluster
- type Redis
- type RedisConf
- type Sentinel
- type ZSetMember
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 单机模式
func (*Client) CheckSetMember ¶
CheckSetMember 检查成员是否在集合内
func (*Client) GetHashField ¶
GetHashField 获取执行hash的指定field数据 TODO: @zcf 当field对应的数据为非string数据类型时, 需要对该方法进行改造(例如: 返回[]byte); 如果要改造,需要对redis interface同步修改
func (*Client) GetMixed ¶
GetMixed 获取到key对应的value mixed redis's basic type TODO: @zcf 根据实际应用,考虑在功能前加入对"key是否存在进行判断"
func (*Client) IsExist ¶
******************************** 通用接口 ************************************* IsExist 判断key是否存在
func (*Client) MembersWithScoreZSet ¶
MembersWithScoreZSet 从高到低获取有序集合的成员及分数
func (*Client) Publish ¶
********************************** pubsub接口 ***************************************
func (*Client) RemMembersZSet ¶
RemMembersZSet 移除key有序集合中的members
func (*Client) SetHash ¶
SetHash设置hash数据
HMSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})
TODO: @zcf redis 的Hash不支持 层级结构
func (*Client) SetStr ¶
******************************** string接口 ************************************* Set 设置key数据(不含TTL)
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster 集群模式
func (*Cluster) CheckSetMember ¶
CheckSetMember 检查成员是否在集合内
func (*Cluster) GetHashField ¶
GetHashField 获取执行hash的指定field数据 TODO: @zcf 当field对应的数据为非string数据类型时, 需要对该方法进行改造(例如: 返回[]byte); 如果要改造,需要对redis interface同步修改
func (*Cluster) GetMixed ¶
GetMixed 获取到key对应的value mixed redis's basic type TODO: @zcf 根据实际应用,考虑在功能前加入对"key是否存在进行判断"
func (*Cluster) IsExist ¶
******************************** 通用接口 ************************************* IsExist 判断key是否存在
func (*Cluster) MembersWithScoreZSet ¶
MembersWithScoreZSet 从高到低获取有序集合的成员及分数
func (*Cluster) Publish ¶
********************************** pubsub接口 ***************************************
func (*Cluster) RemMembersZSet ¶
RemMembersZSet 移除key有序集合中的members
func (*Cluster) SetHash ¶
SetHash设置hash数据
HMSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})
TODO: @zcf redis 的Hash不支持 层级结构
func (*Cluster) SetStr ¶
******************************** string接口 ************************************* Set 设置key数据(不含TTL)
type DeployMode ¶
type DeployMode string
声明支持的redis部署模式
const ( ClientMod DeployMode = "client" // 单机模式 ClusterMod DeployMode = "cluster" // 集群模式 SentinelMod DeployMode = "sentinel" // 哨兵模式 )
type OptionFunc ¶
type OptionFunc func(*redis.Options)
type OptionFuncForCluster ¶
type OptionFuncForCluster func(*redis.ClusterOptions)
type Redis ¶
type Redis interface { IsExist(ctx context.Context, key ...string) bool FlushDB(ctx context.Context, isAll bool) error Del(ctx context.Context, key ...string) error SetExpire(ctx context.Context, key string, ttl time.Duration) error GetExpire(ctx context.Context, key string) (time.Duration, error) GetMixed(ctx context.Context, key string, value interface{}) error ScanKey(ctx context.Context, match string) chan string SetStr(ctx context.Context, key, value string) error SetStrTTL(ctx context.Context, key, value string, ttl time.Duration) error SetNX(ctx context.Context, key, value string, ttl time.Duration) error SetHash(ctx context.Context, key string, value map[string]interface{}) error GetHashField(ctx context.Context, key, field string) (string, error) PushList(ctx context.Context, key string, values ...interface{}) error LenList(ctx context.Context, key string) (int64, error) PopList(ctx context.Context, key string, value interface{}) error AddSet(ctx context.Context, key string, values ...interface{}) error CheckSetMember(ctx context.Context, key string, value interface{}) (bool, error) RemSetEle(ctx context.Context, key string, values ...interface{}) error AddZSet(ctx context.Context, key string, members ...*ZSetMember) error CardZSet(ctx context.Context, key string) (int64, error) MembersWithScoreZSet(ctx context.Context, key string) ([]*ZSetMember, error) RemMembersZSet(ctx context.Context, key string, members ...string) error Publish(ctx context.Context, channel string, message interface{}) error Subscribe(ctx context.Context, channels ...string) (<-chan *Message, error) }
func InitRedisClient ¶
InitRedisClient 实例化redis连接对象
func NewCluster ¶
type RedisConf ¶
type RedisConf struct { DeployMode DeployMode `json:"deployMode"` Endpoints []string `json:"endpoints"` User string `json:"user"` Password string `json:"passwd"` Db int `json:"db"` }
RedisConf redis的连接配置 nolint
type ZSetMember ¶
type ZSetMember struct { Score float64 `json:"score"` Member interface{} `json:"member"` }
ZSetMember 有序集合的数据结构