Documentation ¶
Index ¶
- func TestRole(c redis.Conn, expectedRole string) bool
- type NoSentinelsAvailable
- type RedisPool
- func (r *RedisPool) Delete(key string) error
- func (r *RedisPool) Exist(key string) (bool, error)
- func (r *RedisPool) Get(key string) (interface{}, error)
- func (r *RedisPool) GetBool(key string) (bool, error)
- func (r *RedisPool) GetBytes(key string) ([]byte, error)
- func (r *RedisPool) GetFloat64(key string) (float64, error)
- func (r *RedisPool) GetFloat64s(key string) ([]float64, error)
- func (r *RedisPool) GetInt(key string) (int, error)
- func (r *RedisPool) GetInt64(key string) (int64, error)
- func (r *RedisPool) GetInt64Map(key string) (map[string]int64, error)
- func (r *RedisPool) GetInt64s(key string) ([]int64, error)
- func (r *RedisPool) GetIntMap(key string) (map[string]int, error)
- func (r *RedisPool) GetInts(key string) ([]int, error)
- func (r *RedisPool) GetString(key string) (string, error)
- func (r *RedisPool) GetTTL(key string) (int, error)
- func (r *RedisPool) GetUint64(key string) (uint64, error)
- func (r *RedisPool) HDel(key string, field string) error
- func (r *RedisPool) HExist(key string, fields string) (bool, error)
- func (r *RedisPool) HGet(key string, field string) (interface{}, error)
- func (r *RedisPool) HGetAllMapInt(key string) (map[string]int, error)
- func (r *RedisPool) HGetAllMapInt64(key string) (map[string]int64, error)
- func (r *RedisPool) HGetAllMapString(key string) (map[string]string, error)
- func (r *RedisPool) HGetAllToStruct(key string, m *struct{}) error
- func (r *RedisPool) HGetBool(key, field string) (bool, error)
- func (r *RedisPool) HGetBytes(key, field string) ([]byte, error)
- func (r *RedisPool) HGetFloat64(key, field string) (float64, error)
- func (r *RedisPool) HGetFloat64s(key, field string) ([]float64, error)
- func (r *RedisPool) HGetInt(key, field string) (int, error)
- func (r *RedisPool) HGetInt64(key, field string) (int64, error)
- func (r *RedisPool) HGetInt64Map(key, field string) (map[string]int64, error)
- func (r *RedisPool) HGetInt64s(key, field string) ([]int64, error)
- func (r *RedisPool) HGetIntMap(key, field string) (map[string]int, error)
- func (r *RedisPool) HGetInts(key, field string) ([]int, error)
- func (r *RedisPool) HGetString(key, field string) (string, error)
- func (r *RedisPool) HGetUint64(key, field string) (uint64, error)
- func (r *RedisPool) HMSet(key string, field string, value interface{}) error
- func (r *RedisPool) HMSetMapField(key string, fields map[string]interface{}) error
- func (r *RedisPool) HSet(key string, field string, value interface{}) error
- func (r *RedisPool) IsErrNil(err error) bool
- func (r *RedisPool) LPop(key string) (interface{}, error)
- func (r *RedisPool) LPopBool(key string) (bool, error)
- func (r *RedisPool) LPopBytes(key string) ([]byte, error)
- func (r *RedisPool) LPopFloat64(key string) (float64, error)
- func (r *RedisPool) LPopFloat64s(key string) ([]float64, error)
- func (r *RedisPool) LPopInt(key string) (int, error)
- func (r *RedisPool) LPopInt64(key string) (int64, error)
- func (r *RedisPool) LPopInt64Map(key string) (map[string]int64, error)
- func (r *RedisPool) LPopInt64s(key string) ([]int64, error)
- func (r *RedisPool) LPopIntMap(key string) (map[string]int, error)
- func (r *RedisPool) LPopInts(key string) ([]int, error)
- func (r *RedisPool) LPopString(key string) (string, error)
- func (r *RedisPool) LPopUint64(key string) (uint64, error)
- func (r *RedisPool) LPush(key string, value interface{}) error
- func (r *RedisPool) Set(key string, value interface{}) error
- func (r *RedisPool) SetTTL(key string, ttl int64) error
- func (r *RedisPool) SetWithTTL(key string, ttl int64, value interface{}) error
- type Sentinel
- type SentinelConfig
- type Slave
- type StandAloneConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestRole ¶
TestRole wraps GetRole in a test to verify if the role matches an expected role string. If there was any error in querying the supplied connection, the function returns false. Works with Redis >= 2.8.12. It's not goroutine safe, but if you call this method on pooled connections then you are OK.
Types ¶
type NoSentinelsAvailable ¶
type NoSentinelsAvailable struct {
// contains filtered or unexported fields
}
NoSentinelsAvailable is returned when all sentinels in the list are exhausted (or none configured), and contains the last error returned by Dial (which may be nil)
func (NoSentinelsAvailable) Error ¶
func (ns NoSentinelsAvailable) Error() string
type RedisPool ¶
type RedisPool struct {
// contains filtered or unexported fields
}
RedisPool Redis资源池结构体
func NewClusterPool ¶
func NewRedisPool ¶
func NewRedisPool(cfg *StandAloneConfig) (*RedisPool, error)
func NewSentinelPool ¶
func NewSentinelPool(cfg *SentinelConfig) (*RedisPool, error)
func (*RedisPool) GetInt64Map ¶
func (*RedisPool) HGetAllMapInt ¶
func (*RedisPool) HGetAllMapInt64 ¶
func (*RedisPool) HGetAllMapString ¶
func (*RedisPool) HGetAllToStruct ¶
func (*RedisPool) HGetFloat64s ¶
func (*RedisPool) HGetInt64Map ¶
func (*RedisPool) HGetIntMap ¶
func (*RedisPool) HMSetMapField ¶
func (*RedisPool) LPopInt64Map ¶
type Sentinel ¶
type Sentinel struct { // Addrs is a slice with known Sentinel addresses. Addrs []string // MasterName is a name of Redis master Sentinel servers monitor. MasterName string // Dial is a user supplied function to connect to Sentinel on given address. This // address will be chosen from Addrs slice. // Note that as per the redis-sentinel client guidelines, a timeout is mandatory // while connecting to Sentinels, and should not be set to 0. Dial func(addr string) (redis.Conn, error) // Pool is a user supplied function returning custom connection pool to Sentinel. // This can be useful to tune options if you are not satisfied with what default // Sentinel pool offers. See defaultPool() method for default pool implementation. // In most cases you only need to provide Dial function and let this be nil. Pool func(addr string) *redis.Pool // contains filtered or unexported fields }
func (*Sentinel) Discover ¶
Discover allows to update list of known Sentinel addresses. From docs:
A client may update its internal list of Sentinel nodes following this procedure: 1) Obtain a list of other Sentinels for this master using the command SENTINEL sentinels <master-name>. 2) Add every ip:port pair not already existing in our list at the end of the list.
func (*Sentinel) MasterAddr ¶
MasterAddr returns an address of current Redis master instance.
func (*Sentinel) SentinelAddrs ¶
SentinelAddrs returns a slice of known Sentinel addresses Sentinel server aware of.
func (*Sentinel) SlaveAddrs ¶
SlaveAddrs returns a slice with known slave addresses of current master instance.
type SentinelConfig ¶
type SentinelConfig struct { Cluster []string //集群主机列表 MasterName string //集群Master名字 SentinelPass string //哨兵连接密码 Authpass string //Redis连接密码 KeepAlive int64 //链接空闲超时时间,单位秒(s) MaxIdle int //最大空闲连接 MaxActive int //最大活动连接 ConnectTimeout int //连接操作超时时间,单位毫秒(ms) ReadTimeout int //读操作超时时间,单位毫秒(ms) WriteTimeout int //写操作超时时间,单位毫秒(ms) }