lock_ridis

package
v0.0.0-...-b628505 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockFailed   = errors.New("获取锁失败")
	ErrUnLockFailed = errors.New("释放锁失败")
	CMDLock         = `` /* 193-byte string literal not displayed */

	CMDUnlock = `if redis.call("GET", KEYS[1]) == ARGV[1] then
    return redis.call("DEL", KEYS[1])
else
    return 0
end`
)

Functions

func LeaseLock

func LeaseLock(lock locker.Locker, key string, expire int, ops ...options.Option) (func() error, error)

func NewRedisLock

func NewRedisLock(client redis.UniversalClient, opts ...options.Option) locker.Locker

func SetInterval

func SetInterval(duration time.Duration) options.Option

SetInterval 设置重试间隔时间

func SetLeaseEnable

func SetLeaseEnable(enable bool) options.Option

func SetLeaseInterval

func SetLeaseInterval(duration time.Duration) options.Option

func SetLeaseLogger

func SetLeaseLogger(logger log.Logger) options.Option

func SetLeaseRandomNum

func SetLeaseRandomNum(randomNum int) options.Option

func SetRetries

func SetRetries(retries int) options.Option

SetRetries 设置重试次数

Types

type Lock

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

func (*Lock) Lock

func (l *Lock) Lock(key string, expire int, mark string) error

func (*Lock) UnLock

func (l *Lock) UnLock(key string, mark string) error

Jump to

Keyboard shortcuts

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