Documentation ¶
Overview ¶
Package redis (go-sentinel): https://github.com/FZambia/sentinel
Index ¶
- func TestRole(c redis.Conn, expectedRole string) bool
- type ConnPool
- func (rc *ConnPool) Brpop(key string, timeoutSeconds int) ([]string, error)
- func (rc *ConnPool) Decr(key string) (int64, error)
- func (rc *ConnPool) DelKey(key string) (interface{}, error)
- func (rc *ConnPool) ExistsKey(key string) (bool, error)
- func (rc *ConnPool) ExpireKey(key string, seconds int) (interface{}, error)
- func (rc *ConnPool) Get(key string) (string, error)
- func (rc *ConnPool) GetErrNil(key string) (string, error)
- func (rc *ConnPool) Hdel(key string, field []string) (interface{}, error)
- func (rc *ConnPool) Hexists(key string, field string) (bool, error)
- func (rc *ConnPool) Hget(key string, field string) (string, error)
- func (rc *ConnPool) Hgetall(key string) (map[string]string, error)
- func (rc *ConnPool) Hlen(key string) (int, error)
- func (rc *ConnPool) Hmget(key string, field []string) ([]string, error)
- func (rc *ConnPool) Hmset(key string, fieldValue map[string]string) (interface{}, error)
- func (rc *ConnPool) Hset(key string, field string, value string) (interface{}, error)
- func (rc *ConnPool) Incr(key string) (int64, error)
- func (rc *ConnPool) Llen(key string) (int, error)
- func (rc *ConnPool) Lpush(key string, value []string) (interface{}, error)
- func (rc *ConnPool) LuaScriptZset(script, key string, score int64, member string) (interface{}, error)
- func (rc *ConnPool) Rpop(key string) (string, error)
- func (rc *ConnPool) Sadd(key string, member []string) (interface{}, error)
- func (rc *ConnPool) Scard(key string) (int, error)
- func (rc *ConnPool) Set(key string, value string) (interface{}, error)
- func (rc *ConnPool) SetExpire(key string, value string, seconds int) (interface{}, error)
- func (rc *ConnPool) Smembers(key string) ([]string, error)
- func (rc *ConnPool) Srem(key string, member []string) (interface{}, error)
- func (rc *ConnPool) Zadd(key string, score int64, member string) (interface{}, error)
- func (rc *ConnPool) Zcard(key string) (int, error)
- func (rc *ConnPool) Zrange(key string, start, stop int) ([]string, error)
- func (rc *ConnPool) Zrangebyscore(key string, min, max string, offset, limit int) ([]string, error)
- func (rc *ConnPool) Zrem(key string, member string) (interface{}, error)
- func (rc *ConnPool) Zremrangebyrank(key string, start, stop int) (interface{}, error)
- func (rc *ConnPool) Zremrangebyscore(key string, min, max int64) (interface{}, error)
- func (rc *ConnPool) Zrevrange(key string, start, stop int) ([]string, error)
- func (rc *ConnPool) Zrevrangebyscore(key string, max, min string, offset, limit int) ([]string, error)
- type NoSentinelsAvailable
- type Sentinel
- type Slave
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 ConnPool ¶
type ConnPool struct {
// contains filtered or unexported fields
}
ConnPool redis连接池
func (*ConnPool) LuaScriptZset ¶
func (rc *ConnPool) LuaScriptZset(script, key string, score int64, member string) (interface{}, error)
LuaScriptZset for SortedSet
func (*ConnPool) Zrangebyscore ¶
Zrangebyscore for SortedSet all: -inf ~ +inf min ~ max min-max: (min ~ (max
func (*ConnPool) Zremrangebyrank ¶
Zremrangebyrank for SortedSet
func (*ConnPool) Zremrangebyscore ¶
Zremrangebyscore for SortedSet
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 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 }
Sentinel provides a way to add high availability (HA) to Redis Pool using preconfigured addresses of Sentinel servers and name of master which Sentinels monitor. It works with Redis >= 2.8.12 (mostly because of ROLE command that was introduced in that version, it's possible though to support old versions using INFO command).
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.