Documentation ¶
Overview ¶
redis 实现分布式互斥锁
Index ¶
- Constants
- Variables
- func Decode(encoding string, b []byte, v interface{}) error
- func Encode(encoding string, v interface{}) (interface{}, error)
- func GetPool(redisName string) *redis.Pool
- func GetRedisPoolClient(redisName string) (conn redis.Conn)
- func Install(configs []*Config)
- func MustGetPool(redisName string) *redis.Pool
- func NewMutex(redisName, key string) *redsync.Mutex
- func NewRedisPool(c *Config) *redis.Pool
- func Warn(err error)
- type Config
- type Key
- func (this *Key) BitCount() int
- func (this *Key) Del() *Result
- func (this *Key) Do(command string, args ...interface{}) *Result
- func (this *Key) Exists() bool
- func (this *Key) Expire(ttl int) bool
- func (this *Key) GeoAdd(member interface{}, lat, lng float64) bool
- func (this *Key) GeoDist(m1, m2 interface{}) int
- func (this *Key) GeoMPos(members ...interface{}) [][2]float64
- func (this *Key) GeoPos(member interface{}) (float64, float64)
- func (this *Key) Get() *Result
- func (this *Key) HDel(fields ...interface{}) *Result
- func (this *Key) HExists(key ...interface{}) bool
- func (this *Key) HGet(fields ...interface{}) *Result
- func (this *Key) HGetAll() *Result
- func (this *Key) HIncrBy(d int) *Result
- func (this *Key) HIncrBy2(field interface{}, d int) *Result
- func (this *Key) HKeys(fields ...interface{}) *Result
- func (this *Key) HLen() int
- func (this *Key) HMGet(fields ...interface{}) *Result
- func (this *Key) HMSet(fields ...interface{}) *Result
- func (this *Key) HScanEx() *Result
- func (this *Key) HSet(value interface{}) *Result
- func (this *Key) HSet2(key, value interface{}) *Result
- func (this *Key) HSetNX(value interface{}) *Result
- func (this *Key) HSetNX2(key, value interface{}) *Result
- func (this *Key) Incr() *Result
- func (this *Key) IncrBy(amount int) *Result
- func (this *Key) LPop() *Result
- func (this *Key) LuaIncrBy(amount int) *Result
- func (this *Key) RPush(args ...interface{}) int
- func (this *Key) SAdd(members ...interface{}) bool
- func (this *Key) SCard() *Result
- func (this *Key) SIsMember(member interface{}) bool
- func (this *Key) SMembers() *Result
- func (this *Key) SPop(count int) *Result
- func (this *Key) SRandMember(count int) *Result
- func (this *Key) SRem(members ...interface{}) bool
- func (this *Key) Set(value interface{}) *Result
- func (this *Key) SetBit(offset int, value int) bool
- func (this *Key) SetEX(value interface{}, timeout int) *Result
- func (this *Key) SetNX(value interface{}) *Result
- func (this *Key) TTL() int
- func (this *Key) ZAdd(member, score interface{}) bool
- func (this *Key) ZAddNX(member, score interface{}) bool
- func (this *Key) ZAddXX(member, score interface{}) bool
- func (this *Key) ZCard() int
- func (this *Key) ZExists(member interface{}) bool
- func (this *Key) ZIncrBy(member interface{}, d interface{}) *Result
- func (this *Key) ZPopMin(count int) []string
- func (this *Key) ZRank(member interface{}) int
- func (this *Key) ZRem(member interface{}) bool
- func (this *Key) ZRemRangeByScore(min interface{}, max interface{}) int
- func (this *Key) ZRevRank(member interface{}) int
- func (this *Key) ZScore(member interface{}) *Result
- type Result
- func (this *Result) Bool() bool
- func (this *Result) Bytes() []byte
- func (this *Result) Float64() float64
- func (this *Result) Float64s() []float64
- func (this *Result) Int() int
- func (this *Result) Int32() int32
- func (this *Result) Int32s() []int32
- func (this *Result) Int64() int64
- func (this *Result) Int64Map() map[string]int64
- func (this *Result) Int64s() []int64
- func (this *Result) IntMap() map[string]int
- func (this *Result) Ints() []int
- func (this *Result) String() string
- func (this *Result) StringMap() map[string]string
- func (this *Result) Strings() []string
- func (this *Result) Unmarshal(v interface{}) error
- func (this *Result) Values() []interface{}
Constants ¶
View Source
const ( Minite = 60 Hour = 60 * Minite Day = 24 * Hour Month = 30 * Day )
Variables ¶
View Source
var Decoders map[string]func(data []byte, v interface{}) error
View Source
var Encoders map[string]func(v interface{}) ([]byte, error)
View Source
var ErrNil = errors.New("cache: nil returned")
View Source
var ErrNilDecoder = errors.New("cache: nil decoder")
View Source
var ErrNilEncoder = errors.New("cache: nil encoder")
Functions ¶
func GetRedisPoolClient ¶
func MustGetPool ¶
func NewRedisPool ¶
Types ¶
type Config ¶
type Config struct { Name string `json:"name"` Addr string `json:"addr"` Active int `json:"active"` Idle int `json:"idle"` DialTimeout int `json:"dial_timeout"` // millisecond ReadTimeout int `json:"read_timeout"` // millisecond WriteTimeout int `json:"write_timeout"` // millisecond IdleTimeout int `json:"idle_timeout"` // second DBNum int `json:"dbnum"` Password string `json:"password"` }
type Key ¶
type Key struct { DBName string // redis连接池名 Key interface{} // 主键名 SecondaryKey interface{} // (可选)次级键名, 用于哈希或集合操作, 比如hget <key> <field> Encoding string // 序列化方式, msgpack/json/自定义 Timeout int // 过期时间(秒) Critical bool // 是否关键key. true=只要读写报错就panic }
func (*Key) SRandMember ¶
func (*Key) ZPopMin ¶
Removes and returns up to count members with the lowest scores in the sorted set stored at key. Returns: list of popped elements and scores.
func (*Key) ZRemRangeByScore ¶
Redis Zremrangebyscore 命令用于移除有序集中,指定分数(score)区间内的所有成员。
Click to show internal directories.
Click to hide internal directories.