sync

package module
v0.0.0-...-68bec54 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 6 Imported by: 1

README

sync

distributed sync lock

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLockFailed 加锁失败
	ErrLockFailed = errors.New("lock failed")
	// ErrUnlockFailed 解锁失败
	ErrUnlockFailed = errors.New("unlock failed")
)

Functions

This section is empty.

Types

type Mutexer

type Mutexer interface {
	Lock() (err error)
	Unlock() (err error)
}

Mutexer 互斥锁

type Option

type Option func(*Options)

Option 为可选参数赋值的函数

func KeyPrefix

func KeyPrefix(keyPrefix string) Option

KeyPrefix ...

func LockTimeout

func LockTimeout(lockTimeout time.Duration) Option

LockTimeout ...

func WaitRetry

func WaitRetry(waitRetry time.Duration) Option

WaitRetry ...

type Options

type Options struct {
	KeyPrefix   string
	LockTimeout time.Duration
	WaitRetry   time.Duration
}

Options ...

type RedisSync

type RedisSync struct {
	Opts  *Options
	Redis *redis.Client
}

RedisSync ...

func NewRedisSync

func NewRedisSync(redis *redis.Client, opts ...Option) *RedisSync

NewRedisSync ...

func (*RedisSync) NewMutex

func (r *RedisSync) NewMutex(key string, opts ...Option) Mutexer

NewMutex 创建互斥锁

Jump to

Keyboard shortcuts

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