Documentation ¶
Index ¶
- Constants
- func ChnSlot(channel ...interface{}) (int, error)
- func CmdSlot(cmd string, args ...interface{}) int
- func Slot(key string) int
- type ClusterPool
- func (cp *ClusterPool) ActiveCount() int
- func (cp *ClusterPool) Close()
- func (cp *ClusterPool) Get() redis.Conn
- func (cp *ClusterPool) GetAddrsBySlots(slots []int, readOnly bool) ([]string, error)
- func (cp *ClusterPool) GetContext(ctx context.Context) redis.Conn
- func (cp *ClusterPool) GetNoRedirConn() redis.Conn
- func (cp *ClusterPool) GetPubSubConn() (*redis.PubSubConn, error)
- func (cp *ClusterPool) GetRandomRealConn() (redis.Conn, error)
- func (cp *ClusterPool) GetReadonlyConn() redis.Conn
- func (cp *ClusterPool) GetShardedPubSubConn() (*ShardedPubSubConn, error)
- func (cp *ClusterPool) IdleCount() int
- func (cp *ClusterPool) ReloadSlotMapping() error
- func (cp *ClusterPool) Stats() map[string]redis.PoolStats
- func (cp *ClusterPool) VerbosSlotMapping() string
- type RedirInfo
- type ShardedPubSubConn
- func (c *ShardedPubSubConn) Close() error
- func (c *ShardedPubSubConn) Ping(data string) error
- func (c *ShardedPubSubConn) Receive() interface{}
- func (c *ShardedPubSubConn) ReceiveContext(ctx context.Context) interface{}
- func (c *ShardedPubSubConn) ReceiveWithTimeout(timeout time.Duration) interface{}
- func (c *ShardedPubSubConn) SSubscribe(channel ...interface{}) error
- func (c *ShardedPubSubConn) SUnsubscribe(channel ...interface{}) error
Constants ¶
const ( OpNil = 0 OpDO = 1 OpPipeLine = 2 )
const (
TotalSlots = 16384
)
Variables ¶
This section is empty.
Functions ¶
func ChnSlot ¶
ChnSlot returns the channels slot if all channels in the same lost, otherwise returns -1 slot and error
Types ¶
type ClusterPool ¶
type ClusterPool struct { // The entry addresses for cluster, which can be any node address in cluster EntryAddrs []string // Dial options for case without pool(CreateConnPool is nil) DialOptionsWithoutPool []redis.DialOption // Defualt timeout for the connection pool DefaultPoolTimeout time.Duration // Function for creating connection pool, which would be invoked when the caller acquires conn by Getxx func // if the node has not pool in connPools. By this func, you can control the pool behavior based on your demand CreateConnPool func(ctx context.Context, addr string) (*redis.Pool, error) // contains filtered or unexported fields }
func (*ClusterPool) ActiveCount ¶
func (cp *ClusterPool) ActiveCount() int
ActiveCount returns the total active connection count in the cluster pool
func (*ClusterPool) Close ¶
func (cp *ClusterPool) Close()
Close closes the connections and clear the slot mapping of the cluster pool
func (*ClusterPool) Get ¶
func (cp *ClusterPool) Get() redis.Conn
Get gets the redis.Conn interface that handles the redirecting automatically
func (*ClusterPool) GetAddrsBySlots ¶
func (cp *ClusterPool) GetAddrsBySlots(slots []int, readOnly bool) ([]string, error)
func (*ClusterPool) GetContext ¶
func (cp *ClusterPool) GetContext(ctx context.Context) redis.Conn
GetContext gets the redis.Conn interface that handles the redirecting automatically
func (*ClusterPool) GetNoRedirConn ¶
func (cp *ClusterPool) GetNoRedirConn() redis.Conn
GetNoRedirConn gets the redis.Conn interface without redirecting handling, which allows you handling the redirecting
func (*ClusterPool) GetPubSubConn ¶
func (cp *ClusterPool) GetPubSubConn() (*redis.PubSubConn, error)
GetPubSubConn gets the redis.PubSubConn
func (*ClusterPool) GetRandomRealConn ¶
func (cp *ClusterPool) GetRandomRealConn() (redis.Conn, error)
func (*ClusterPool) GetReadonlyConn ¶
func (cp *ClusterPool) GetReadonlyConn() redis.Conn
GetConnWithoutRedir gets the redis.Conn interface without redirecting handling, which allows you handling the redirecting
func (*ClusterPool) GetShardedPubSubConn ¶
func (cp *ClusterPool) GetShardedPubSubConn() (*ShardedPubSubConn, error)
GetShardedPubSubConn gets the ShardedPubSubConn
func (*ClusterPool) IdleCount ¶
func (cp *ClusterPool) IdleCount() int
IdleCount returns the total idle connection count in the cluster pool
func (*ClusterPool) ReloadSlotMapping ¶
func (cp *ClusterPool) ReloadSlotMapping() error
ReloadSlots reloads the slot mapping
func (*ClusterPool) Stats ¶
func (cp *ClusterPool) Stats() map[string]redis.PoolStats
Stats gets the redis.PoolStats of the current cluster
func (*ClusterPool) VerbosSlotMapping ¶
func (cp *ClusterPool) VerbosSlotMapping() string
VerbosSlots returns the slot mapping of the cluster with a readable string
type RedirInfo ¶
type RedirInfo struct { // Kind indicates the redirection type, MOVED or ASK Kind string // Slot is the slot number of the redirecting Slot int // Addr is the node address to redirect to Addr string // Raw is the original error string Raw string }
func ParseRedirInfo ¶
ParseRedirInfo parses the redirecting error into redirInfo
type ShardedPubSubConn ¶
type ShardedPubSubConn struct {
// contains filtered or unexported fields
}
ShardedPubSubConn wraps a Conn with convenience API for sharded PubSub.
func (*ShardedPubSubConn) Close ¶
func (c *ShardedPubSubConn) Close() error
Close closes the connection.
func (*ShardedPubSubConn) Ping ¶
func (c *ShardedPubSubConn) Ping(data string) error
Ping sends a PING to the server with the specified data. The connection must be subscribed to at least one channel or pattern when calling this method.
func (*ShardedPubSubConn) Receive ¶
func (c *ShardedPubSubConn) Receive() interface{}
Receive returns a pushed message as a Subscription, Message, Pong or error.
func (*ShardedPubSubConn) ReceiveContext ¶
func (c *ShardedPubSubConn) ReceiveContext(ctx context.Context) interface{}
ReceiveContext is like Receive, but it allows termination of the receive via a Context. If the call returns due to closure of the context's Done channel the underlying Conn will have been closed.
func (*ShardedPubSubConn) ReceiveWithTimeout ¶
func (c *ShardedPubSubConn) ReceiveWithTimeout(timeout time.Duration) interface{}
ReceiveWithTimeout is like Receive, but it allows the application to override the connection's default timeout.
func (*ShardedPubSubConn) SSubscribe ¶
func (c *ShardedPubSubConn) SSubscribe(channel ...interface{}) error
Subscribe subscribes the connection to the specified channels.
func (*ShardedPubSubConn) SUnsubscribe ¶
func (c *ShardedPubSubConn) SUnsubscribe(channel ...interface{}) error
SUnsubscribe unsubscribes the connection from the given sharded channels, or from all of them if none is given.