dlock

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockRetryOptions

type LockRetryOptions struct {
	Count    uint32        //重试次数
	Interval time.Duration //重试间隔
}

LockRetryOptions 重试选项

type MemcacheDLocker

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

MemcacheDLocker MC分布式锁

func NewMemcacheDLocker

func NewMemcacheDLocker(mc *memcache.Client) *MemcacheDLocker

NewMemcacheDLocker 新建一个locker对象

func (*MemcacheDLocker) Lock

func (l *MemcacheDLocker) Lock(key string, expiration int32, opt LockRetryOptions) (bool, error)

Lock 给key加锁 key: MC对应的key expiration: 过期时间 单位秒 opt: 重试选项

func (*MemcacheDLocker) Unlock

func (l *MemcacheDLocker) Unlock(key string, opt LockRetryOptions) error

Unlock 释放某个key锁 key: MC对应的key opt: 重试选项

Jump to

Keyboard shortcuts

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