distributed

package
v0.2.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLock = errors.New("is lock")

Functions

This section is empty.

Types

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

Locker 分布式锁.

func NewLocker

func NewLocker(client redis.Cmdable, times ...time.Duration) *Locker

NewLocker 新建分布式锁. times[0] 锁时间, times[1] 续期间隔.

func (*Locker) AutoExpire

func (p *Locker) AutoExpire()

AutoExpire 自动续期.

func (*Locker) Lock

func (p *Locker) Lock(key string, call func() error) error

Lock 锁成功则执行,执行完毕解锁.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL