Documentation
¶
Index ¶
- Constants
- type ConnFactory
- type HAConfig
- type HAConnFactory
- type Pool
- func (p *Pool) Append(ctx context.Context, key, value string) *redis.IntCmd
- func (p *Pool) BLPop(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd
- func (p *Pool) BRPop(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd
- func (p *Pool) BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *redis.StringCmd
- func (p *Pool) BitCount(ctx context.Context, key string, bitCount *redis.BitCount) *redis.IntCmd
- func (p *Pool) BitField(ctx context.Context, key string, args ...interface{}) *redis.IntSliceCmd
- func (p *Pool) BitOp(ctx context.Context, op int, destKey string, keys ...string) *redis.IntCmd
- func (p *Pool) BitOpAnd(ctx context.Context, destKey string, keys ...string) *redis.IntCmd
- func (p *Pool) BitOpNot(ctx context.Context, destKey string, key string) *redis.IntCmd
- func (p *Pool) BitOpOr(ctx context.Context, destKey string, keys ...string) *redis.IntCmd
- func (p *Pool) BitOpXor(ctx context.Context, destKey string, keys ...string) *redis.IntCmd
- func (p *Pool) BitPos(ctx context.Context, key string, bit int64, pos ...int64) *redis.IntCmd
- func (p *Pool) Close()
- func (p *Pool) DebugObject(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) Decr(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) DecrBy(ctx context.Context, key string, decrement int64) *redis.IntCmd
- func (p *Pool) Del(ctx context.Context, keys ...string) (int64, error)
- func (p *Pool) Dump(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) Echo(ctx context.Context, message interface{}) *redis.StringCmd
- func (p *Pool) Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
- func (p *Pool) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
- func (p *Pool) Exists(ctx context.Context, keys ...string) (int64, error)
- func (p *Pool) Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
- func (p *Pool) ExpireAt(ctx context.Context, key string, tm time.Time) *redis.BoolCmd
- func (p *Pool) FlushDB(ctx context.Context) *redis.StatusCmd
- func (p *Pool) FlushDBAsync(ctx context.Context) *redis.StatusCmd
- func (p *Pool) GeoAdd(ctx context.Context, key string, geoLocation ...*redis.GeoLocation) *redis.IntCmd
- func (p *Pool) GeoDist(ctx context.Context, key string, member1, member2, unit string) *redis.FloatCmd
- func (p *Pool) GeoHash(ctx context.Context, key string, members ...string) *redis.StringSliceCmd
- func (p *Pool) GeoPos(ctx context.Context, key string, members ...string) *redis.GeoPosCmd
- func (p *Pool) GeoRadius(ctx context.Context, key string, longitude, latitude float64, ...) *redis.GeoLocationCmd
- func (p *Pool) GeoRadiusByMember(ctx context.Context, key, member string, query *redis.GeoRadiusQuery) *redis.GeoLocationCmd
- func (p *Pool) GeoRadiusByMemberStore(ctx context.Context, key, member string, query *redis.GeoRadiusQuery) *redis.IntCmd
- func (p *Pool) GeoRadiusStore(ctx context.Context, key string, longitude, latitude float64, ...) *redis.IntCmd
- func (p *Pool) Get(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) GetBit(ctx context.Context, key string, offset int64) *redis.IntCmd
- func (p *Pool) GetRange(ctx context.Context, key string, start, end int64) *redis.StringCmd
- func (p *Pool) GetSet(ctx context.Context, key string, value interface{}) *redis.StringCmd
- func (p *Pool) HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd
- func (p *Pool) HExists(ctx context.Context, key, field string) *redis.BoolCmd
- func (p *Pool) HGet(ctx context.Context, key, field string) *redis.StringCmd
- func (p *Pool) HGetAll(ctx context.Context, key string) *redis.MapStringStringCmd
- func (p *Pool) HIncrBy(ctx context.Context, key, field string, incr int64) *redis.IntCmd
- func (p *Pool) HIncrByFloat(ctx context.Context, key, field string, incr float64) *redis.FloatCmd
- func (p *Pool) HKeys(ctx context.Context, key string) *redis.StringSliceCmd
- func (p *Pool) HLen(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) HMGet(ctx context.Context, key string, fields ...string) *redis.SliceCmd
- func (p *Pool) HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd
- func (p *Pool) HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *redis.ScanCmd
- func (p *Pool) HSet(ctx context.Context, key, field string, value interface{}) *redis.IntCmd
- func (p *Pool) HSetNX(ctx context.Context, key, field string, value interface{}) *redis.BoolCmd
- func (p *Pool) HVals(ctx context.Context, key string) *redis.StringSliceCmd
- func (p *Pool) Incr(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) IncrBy(ctx context.Context, key string, increment int64) *redis.IntCmd
- func (p *Pool) IncrByFloat(ctx context.Context, key string, value float64) *redis.FloatCmd
- func (p *Pool) LIndex(ctx context.Context, key string, index int64) *redis.StringCmd
- func (p *Pool) LInsert(ctx context.Context, key, op string, pivot, value interface{}) *redis.IntCmd
- func (p *Pool) LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *redis.IntCmd
- func (p *Pool) LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *redis.IntCmd
- func (p *Pool) LLen(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) LPop(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) LPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
- func (p *Pool) LPushX(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
- func (p *Pool) LRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd
- func (p *Pool) LRem(ctx context.Context, key string, count int64, value interface{}) *redis.IntCmd
- func (p *Pool) LSet(ctx context.Context, key string, index int64, value interface{}) *redis.StatusCmd
- func (p *Pool) LTrim(ctx context.Context, key string, start, stop int64) *redis.StatusCmd
- func (p *Pool) MExpire(ctx context.Context, expiration time.Duration, keys ...string) map[string]error
- func (p *Pool) MExpireAt(ctx context.Context, tm time.Time, keys ...string) map[string]error
- func (p *Pool) MGet(ctx context.Context, keys ...string) ([]interface{}, error)
- func (p *Pool) MGetWithGD(ctx context.Context, keys ...string) ([]interface{}, map[string]error)
- func (p *Pool) MSet(ctx context.Context, values ...interface{}) *redis.StatusCmd
- func (p *Pool) MSetNX(ctx context.Context, values ...interface{}) *redis.BoolCmd
- func (p *Pool) MSetWithGD(ctx context.Context, values ...interface{}) []*redis.StatusCmd
- func (p *Pool) MemoryUsage(ctx context.Context, key string, samples ...int) *redis.IntCmd
- func (p *Pool) ObjectEncoding(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) ObjectIdleTime(ctx context.Context, key string) *redis.DurationCmd
- func (p *Pool) ObjectRefCount(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) PFAdd(ctx context.Context, key string, els ...interface{}) *redis.IntCmd
- func (p *Pool) PFCount(ctx context.Context, keys ...string) *redis.IntCmd
- func (p *Pool) PFMerge(ctx context.Context, dest string, keys ...string) *redis.StatusCmd
- func (p *Pool) Ping(ctx context.Context) *redis.StatusCmd
- func (p *Pool) Pipeline() (redis.Pipeliner, error)
- func (p *Pool) Pipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)
- func (p *Pool) PubSubChannels(ctx context.Context, pattern string) *redis.StringSliceCmd
- func (p *Pool) PubSubNumPat(ctx context.Context) *redis.IntCmd
- func (p *Pool) PubSubNumSub(ctx context.Context, channels ...string) *redis.MapStringIntCmd
- func (p *Pool) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd
- func (p *Pool) RPop(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) RPopLPush(ctx context.Context, source, destination string) *redis.StringCmd
- func (p *Pool) RPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
- func (p *Pool) RPushX(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
- func (p *Pool) Rename(ctx context.Context, key, newkey string) *redis.StatusCmd
- func (p *Pool) RenameNX(ctx context.Context, key, newkey string) *redis.BoolCmd
- func (p *Pool) SAdd(ctx context.Context, key string, members ...interface{}) *redis.IntCmd
- func (p *Pool) SCard(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) SDiff(ctx context.Context, keys ...string) *redis.StringSliceCmd
- func (p *Pool) SDiffStore(ctx context.Context, destination string, keys ...string) *redis.IntCmd
- func (p *Pool) SInter(ctx context.Context, keys ...string) *redis.StringSliceCmd
- func (p *Pool) SInterStore(ctx context.Context, destination string, keys ...string) *redis.IntCmd
- func (p *Pool) SIsMember(ctx context.Context, key string, member interface{}) *redis.BoolCmd
- func (p *Pool) SMembers(ctx context.Context, key string) *redis.StringSliceCmd
- func (p *Pool) SMembersMap(ctx context.Context, key string) *redis.StringStructMapCmd
- func (p *Pool) SMove(ctx context.Context, source, destination string, member interface{}) *redis.BoolCmd
- func (p *Pool) SPop(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) SPopN(ctx context.Context, key string, count int64) *redis.StringSliceCmd
- func (p *Pool) SRandMember(ctx context.Context, key string) *redis.StringCmd
- func (p *Pool) SRandMemberN(ctx context.Context, key string, count int64) *redis.StringSliceCmd
- func (p *Pool) SRem(ctx context.Context, key string, members ...interface{}) *redis.IntCmd
- func (p *Pool) SScan(ctx context.Context, key string, cursor uint64, match string, count int64) *redis.ScanCmd
- func (p *Pool) SUnion(ctx context.Context, keys ...string) *redis.StringSliceCmd
- func (p *Pool) SUnionStore(ctx context.Context, destination string, keys ...string) *redis.IntCmd
- func (p *Pool) Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd
- func (p *Pool) ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd
- func (p *Pool) ScriptFlush(ctx context.Context) *redis.StatusCmd
- func (p *Pool) ScriptKill(ctx context.Context) *redis.StatusCmd
- func (p *Pool) ScriptLoad(ctx context.Context, script string) *redis.StringCmd
- func (p *Pool) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
- func (p *Pool) SetArgs(ctx context.Context, key string, value interface{}, a redis.SetArgs) *redis.StatusCmd
- func (p *Pool) SetBit(ctx context.Context, key string, offset int64, value int) *redis.IntCmd
- func (p *Pool) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd
- func (p *Pool) SetRange(ctx context.Context, key string, offset int64, value string) *redis.IntCmd
- func (p *Pool) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd
- func (p *Pool) Sort(ctx context.Context, key string, sort *redis.Sort) *redis.StringSliceCmd
- func (p *Pool) SortInterfaces(ctx context.Context, key string, sort *redis.Sort) *redis.SliceCmd
- func (p *Pool) SortStore(ctx context.Context, key, store string, sort *redis.Sort) *redis.IntCmd
- func (p *Pool) Stats() map[string]*redis.PoolStats
- func (p *Pool) StrLen(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) TTL(ctx context.Context, key string) *redis.DurationCmd
- func (p *Pool) Touch(ctx context.Context, keys ...string) (int64, error)
- func (p *Pool) TxPipeline() (redis.Pipeliner, error)
- func (p *Pool) TxPipelineSlave() (redis.Pipeliner, error)
- func (p *Pool) TxPipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)
- func (p *Pool) Type(ctx context.Context, key string) *redis.StatusCmd
- func (p *Pool) Unlink(ctx context.Context, keys ...string) (int64, error)
- func (p *Pool) WithMaster(key ...string) (*redis.Client, error)
- func (p *Pool) WithMasterShards(keys ...string) (map[*redis.Client][]string, error)
- func (p *Pool) ZAdd(ctx context.Context, key string, members ...redis.Z) *redis.IntCmd
- func (p *Pool) ZAddCh(ctx context.Context, key string, members ...*redis.Z) *redis.IntCmd
- func (p *Pool) ZAddGT(ctx context.Context, key string, members ...redis.Z) *redis.IntCmd
- func (p *Pool) ZAddLT(ctx context.Context, key string, members ...redis.Z) *redis.IntCmd
- func (p *Pool) ZAddNX(ctx context.Context, key string, members ...redis.Z) *redis.IntCmd
- func (p *Pool) ZAddNXCh(ctx context.Context, key string, members ...*redis.Z) *redis.IntCmd
- func (p *Pool) ZAddXX(ctx context.Context, key string, members ...redis.Z) *redis.IntCmd
- func (p *Pool) ZAddXXCh(ctx context.Context, key string, members ...*redis.Z) *redis.IntCmd
- func (p *Pool) ZCard(ctx context.Context, key string) *redis.IntCmd
- func (p *Pool) ZCount(ctx context.Context, key, min, max string) *redis.IntCmd
- func (p *Pool) ZIncr(ctx context.Context, key string, member *redis.Z) *redis.FloatCmd
- func (p *Pool) ZIncrBy(ctx context.Context, key string, increment float64, member string) *redis.FloatCmd
- func (p *Pool) ZIncrNX(ctx context.Context, key string, member *redis.Z) *redis.FloatCmd
- func (p *Pool) ZIncrXX(ctx context.Context, key string, member *redis.Z) *redis.FloatCmd
- func (p *Pool) ZInterStore(ctx context.Context, destination string, store *redis.ZStore) *redis.IntCmd
- func (p *Pool) ZLexCount(ctx context.Context, key, min, max string) *redis.IntCmd
- func (p *Pool) ZPopMax(ctx context.Context, key string, count ...int64) *redis.ZSliceCmd
- func (p *Pool) ZPopMin(ctx context.Context, key string, count ...int64) *redis.ZSliceCmd
- func (p *Pool) ZRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd
- func (p *Pool) ZRangeByLex(ctx context.Context, key string, opt *redis.ZRangeBy) *redis.StringSliceCmd
- func (p *Pool) ZRangeByScore(ctx context.Context, key string, opt *redis.ZRangeBy) *redis.StringSliceCmd
- func (p *Pool) ZRangeByScoreWithScores(ctx context.Context, key string, opt *redis.ZRangeBy) *redis.ZSliceCmd
- func (p *Pool) ZRangeWithScores(ctx context.Context, key string, start, stop int64) *redis.ZSliceCmd
- func (p *Pool) ZRank(ctx context.Context, key, member string) *redis.IntCmd
- func (p *Pool) ZRem(ctx context.Context, key string, members ...interface{}) *redis.IntCmd
- func (p *Pool) ZRemRangeByLex(ctx context.Context, key, min, max string) *redis.IntCmd
- func (p *Pool) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *redis.IntCmd
- func (p *Pool) ZRemRangeByScore(ctx context.Context, key, min, max string) *redis.IntCmd
- func (p *Pool) ZRevRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd
- func (p *Pool) ZRevRangeByLex(ctx context.Context, key string, opt *redis.ZRangeBy) *redis.StringSliceCmd
- func (p *Pool) ZRevRangeByScore(ctx context.Context, key string, opt *redis.ZRangeBy) *redis.StringSliceCmd
- func (p *Pool) ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *redis.ZRangeBy) *redis.ZSliceCmd
- func (p *Pool) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *redis.ZSliceCmd
- func (p *Pool) ZRevRank(ctx context.Context, key, member string) *redis.IntCmd
- func (p *Pool) ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *redis.ScanCmd
- func (p *Pool) ZScore(ctx context.Context, key, member string) *redis.FloatCmd
- func (p *Pool) ZUnionStore(ctx context.Context, dest string, store *redis.ZStore) *redis.IntCmd
- type ShardConfig
- type ShardConnFactory
Constants ¶
const ( // PollByRandom selects the slave factory by random index PollByRandom = iota + 1 // PollByWeight selects the slave factory by weight PollByWeight // PollByRoundRobin selects the slave with round-robin order PollByRoundRobin )
const ( // DistributeByModular selects the sharding factory by modular DistributeByModular = iota + 1 // DistributeByKetama selects the sharding factory by ketama consistent algorithm DistributeByKetama )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnFactory ¶
type ConnFactory interface {
// contains filtered or unexported methods
}
type HAConfig ¶
type HAConfig struct { Master string // the address of the master, e.g. "127.0.0.1:6379" Slaves []string // list of slaves, e.g. ["127.0.0.1:6379", "127.0.0.1:6380"] Password string // the password of the master ReadonlyPassword string // the passsword of slaves Options *redis.Options // redis options Hooks []redis.Hook // optional list of redis hooks PollType int // the slave polling type AutoEjectHost bool // eject the failure host or not ServerFailureLimit int32 // eject if reached `ServerFailureLimit` times of failure ServerRetryTimeout time.Duration // retry the ejected host after `ServerRetryTimeout` MinServerNum int // reserved the min server // contains filtered or unexported fields }
type HAConnFactory ¶
type HAConnFactory struct {
// contains filtered or unexported fields
}
HAConnFactory impls the read/write splits between master and slaves
func NewHAConnFactory ¶
func NewHAConnFactory(cfg *HAConfig) (*HAConnFactory, error)
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewShard ¶
func NewShard(cfg *ShardConfig) (*Pool, error)
func (*Pool) BRPopLPush ¶
func (*Pool) DebugObject ¶
func (*Pool) FlushDBAsync ¶
func (*Pool) GeoRadiusByMember ¶
func (*Pool) GeoRadiusByMemberStore ¶
func (*Pool) GeoRadiusStore ¶
func (*Pool) HIncrByFloat ¶
func (*Pool) IncrByFloat ¶
func (*Pool) LInsertAfter ¶
func (*Pool) LInsertBefore ¶
func (*Pool) MExpire ¶
func (p *Pool) MExpire(ctx context.Context, expiration time.Duration, keys ...string) map[string]error
MExpire gives the result for each group of keys
func (*Pool) MGetWithGD ¶
MGetWithGD is like MGet but returns all the values that it managed to get
func (*Pool) MSet ¶
MSet is like Set but accepts multiple values:
- MSet("key1", "value1", "key2", "value2")
- MSet([]string{"key1", "value1", "key2", "value2"})
- MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})
func (*Pool) MSetNX ¶
MSetNX is like SetNX but accepts multiple values:
- MSetNX("key1", "value1", "key2", "value2")
- MSetNX([]string{"key1", "value1", "key2", "value2"})
- MSetNX(map[string]interface{}{"key1": "value1", "key2": "value2"})
func (*Pool) MSetWithGD ¶
MSetWithGD is like MSet but gives the result for each group of keys
func (*Pool) MemoryUsage ¶
func (*Pool) ObjectEncoding ¶
func (*Pool) ObjectIdleTime ¶
func (*Pool) ObjectRefCount ¶
func (*Pool) Pipeline ¶
Pipeline returns pipeline for HA configuration, to get a pipeline for shards use WithMasterShards
func (*Pool) PubSubChannels ¶
func (*Pool) PubSubNumPat ¶
func (*Pool) PubSubNumSub ¶
func (*Pool) SDiffStore ¶
func (*Pool) SInterStore ¶
func (*Pool) SMembersMap ¶
func (*Pool) SRandMember ¶
func (*Pool) SRandMemberN ¶
func (*Pool) SUnionStore ¶
func (*Pool) ScriptExists ¶
func (*Pool) ScriptFlush ¶
func (*Pool) ScriptKill ¶
func (*Pool) ScriptLoad ¶
func (*Pool) SortInterfaces ¶
func (*Pool) TxPipeline ¶
TxPipeline returns pipeline (with MULTI/EXEC) for HA configuration, to get a pipeline for shards use WithMasterShards
func (*Pool) TxPipelineSlave ¶
func (*Pool) TxPipelined ¶
func (*Pool) WithMaster ¶
func (*Pool) WithMasterShards ¶
WithMasterShards returns master connects for shards with executable keys for them
func (*Pool) ZInterStore ¶
func (*Pool) ZRangeByLex ¶
func (*Pool) ZRangeByScore ¶
func (*Pool) ZRangeByScoreWithScores ¶
func (*Pool) ZRangeWithScores ¶
func (*Pool) ZRemRangeByLex ¶
func (*Pool) ZRemRangeByRank ¶
func (*Pool) ZRemRangeByScore ¶
func (*Pool) ZRevRangeByLex ¶
func (*Pool) ZRevRangeByScore ¶
func (*Pool) ZRevRangeByScoreWithScores ¶
func (*Pool) ZRevRangeWithScores ¶
type ShardConfig ¶
type ShardConnFactory ¶
type ShardConnFactory struct {
// contains filtered or unexported fields
}
func NewShardConnFactory ¶
func NewShardConnFactory(cfg *ShardConfig) (*ShardConnFactory, error)