Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (rc *Client) Del(k ...string) error
- func (rc *Client) Exists(k string) (bool, error)
- func (rc *Client) Expire(k string, expire int64) bool
- func (rc *Client) Get(k string) (string, error)
- func (rc *Client) HashDel(hashKey string, field ...string) error
- func (rc *Client) HashExist(hashKey string, field string) (bool, error)
- func (rc *Client) HashGet(hashKey string, field string) (string, error)
- func (rc *Client) HashGetAll(hashKey string) (map[string]string, error)
- func (rc *Client) HashLen(hashKey string) (int64, error)
- func (rc *Client) HashSet(hashKey string, field string, value string) error
- func (rc *Client) HashSetMap(hashKey string, value map[string]interface{}) error
- func (rc *Client) HashSetNX(hashKey string, field string, value string) (bool, error)
- func (rc *Client) ListLength(listKey string) (int, error)
- func (rc *Client) ListRange(listKey string, start int, stop int) ([]string, error)
- func (rc *Client) ListRemove(listKey string, count int, value string) error
- func (rc *Client) ListTrim(listKey string, start int, stop int) error
- func (rc *Client) RightPush(listKey string, v ...string) error
- func (rc *Client) Set(k string, v string) error
- func (rc *Client) SetExpire(key string, expire int64) error
- func (rc *Client) SetNXWithExpire(k string, v string, expire int64) (bool, error)
- func (rc *Client) SetWithExpire(k string, v string, expire int64) error
- func (rc *Client) Type() string
- type ClientConfig
Constants ¶
View Source
const ( NodeMode = "node" ClusterMode = "cluster" )
Variables ¶
View Source
var ( ErrNil = redis.Nil ErrInvalidExpireParameter = errors.New("expire must be larger than 0") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client Redis客户端
func NewRedisClient ¶
func NewRedisClient(config *ClientConfig) *Client
NewRedisClient 根据传入的Config新建Client
func (*Client) HashGetAll ¶
HashGetAll 获取在哈希表中指定 key 的所有字段和值,不存在值则返回一个非nil的map,其len为0
func (*Client) HashSetMap ¶
HashSetMap 将 map[string]interface 的内容存入对应key的哈希表中
func (*Client) ListLength ¶
ListLength llen 获取列表长度
func (*Client) ListRemove ¶
ListRemove lrem 根据参数 COUNT 的值,移除列表中与参数 VALUE 相等的元素
func (*Client) SetNXWithExpire ¶
SetNXWithExpire sets a key-value pair with expire. True will be returned if target pair not exists, otherwise false will be returned
func (*Client) SetWithExpire ¶
SetWithExpire sets a key-value pair with expire.
type ClientConfig ¶
type ClientConfig struct { Host string Type string `json:",default=node,options=node|cluster"` MinIdle int `json:",default=1"` MaxActive int `json:",default=10"` IdleTimeout time.Duration `json:",default=10s"` Verbose bool `json:",default=false,options=true|false"` Pass string `json:",optional"` ConnectTimeout time.Duration `json:",default=100ms"` ReadTimeout time.Duration `json:",default=100ms"` WriteTimeout time.Duration `json:",default=100ms"` }
ClientConfig 配置信息
Click to show internal directories.
Click to hide internal directories.