redlock

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LockTime      = 3 * time.Second               //默认lock时间
	RetryInterval = 100 * time.Millisecond        //默认间隔时间
	Retries       = int(LockTime / RetryInterval) //默认重试次数
)
View Source
var ErrCanced = errors.New("canced")

Functions

This section is empty.

Types

type Client

type Client struct {
	*redis.Client
}

func NewClient

func NewClient(c *redis.Client) *Client

func (*Client) NewMutex

func (c *Client) NewMutex(key string) *Mutex

type Mutex

type Mutex struct {
	*Client
	// contains filtered or unexported fields
}

Mutext定义

func New

func New(c *Client, key string) *Mutex

key name 不能为空

func (*Mutex) Lock

func (m *Mutex) Lock(d ...time.Duration) error

func (*Mutex) Unlock

func (m *Mutex) Unlock() error

解锁

func (*Mutex) WithContext

func (m *Mutex) WithContext(ctx context.Context) *Mutex

设置context

Jump to

Keyboard shortcuts

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