sync

package
v0.3.32 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockedState   = fmt.Errorf("the current lock is locked")
	ErrNotHolderLock = fmt.Errorf("it is not the holder can not unlock")
)

Functions

This section is empty.

Types

type NoWaitLock

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

NoWaitLock 基于redis 非等待锁

func NewNoWaitLock

func NewNoWaitLock(client *redis.ClusterClient, key string, timeOut time.Duration) (locker *NoWaitLock, err error)

func (*NoWaitLock) Do

func (n *NoWaitLock) Do(f func() error) (err1 error, err2 error)

Do 对执行函数使用 NoWaitLock 进行同步, err1 返回 回调函数有关的错误, err2 返回 锁有关的错误,

func (*NoWaitLock) Lock

func (n *NoWaitLock) Lock() (err error)

func (*NoWaitLock) UnLock

func (n *NoWaitLock) UnLock() (err error)

Jump to

Keyboard shortcuts

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