mutex

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientNil = errors.New("redis client is nil (forgotten initialize?)")
View Source
var Nil = helper.NilError("redlock: nil")

Nil 未获取到锁

Functions

This section is empty.

Types

type Mutex

type Mutex interface {
	// Lock 获取锁(未获取到:err = mutex.Nil)
	Lock(ctx context.Context) error
	// TryLock 尝试获取锁(未获取到:err = mutex.Nil)
	TryLock(ctx context.Context, attempts int, duration time.Duration) error
	// UnLock 释放锁
	UnLock(ctx context.Context) error
}

Mutex 分布式锁

func RedLock

func RedLock(cli redis.UniversalClient, key string, ttl time.Duration) Mutex

RedLock 基于Redis实现的分布式锁实例

Jump to

Keyboard shortcuts

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