Documentation ¶
Overview ¶
Package rdb Redis工具.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLock = errors.New("is lock") ErrExpire = errors.New("expire time too long") )
Functions ¶
This section is empty.
Types ¶
type InstanceNum ¶ added in v0.5.41
type InstanceNum struct {
// contains filtered or unexported fields
}
InstanceNum 实例数量.
func NewInstanceNum ¶ added in v0.5.41
func NewInstanceNum(client redis.Cmdable) *InstanceNum
NewInstanceNum 新建实例数量.
func NewInstanceNumByKey ¶ added in v0.5.41
func NewInstanceNumByKey(client redis.Cmdable, key string) *InstanceNum
func (*InstanceNum) Register ¶ added in v0.5.41
func (p *InstanceNum) Register(observer chan<- uint64)
Register 订阅主题.
func (*InstanceNum) Run ¶ added in v0.5.41
func (p *InstanceNum) Run()
Run 运行.
使用 redis INCR 命令计算一秒内增加的数量得出实例数量.
type Locker ¶ added in v0.5.40
type Locker struct {
// contains filtered or unexported fields
}
Locker 分布式锁.
Example ¶
nolint: testableexamples
client := redis.NewClient(&redis.Options{ Addr: "192.168.1.11:6379", Password: "", DB: 0, }) locker := rdb.NewLocker(client) _ = locker.Lock("test", func() error { // do something return nil })
Output:
Click to show internal directories.
Click to hide internal directories.