redlock

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Nil = helper.NilError("redlock: nil")

Nil 未获取到锁

Functions

This section is empty.

Types

type RedLock

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

RedLock 基于「Redis」实现的分布式锁

注意:单个 RedLock 实例不是并发安全的,同一实例不应被多个 goroutine 共享

func New

func New(uc redis.UniversalClient, key string, ttl time.Duration) *RedLock

New 返回一个Redis分布式锁

func (*RedLock) Acquire

func (l *RedLock) Acquire(ctx context.Context) error

func (*RedLock) Release

func (l *RedLock) Release(ctx context.Context) error

func (*RedLock) TryAcquire

func (l *RedLock) TryAcquire(ctx context.Context, attempts int, duration time.Duration) error

Jump to

Keyboard shortcuts

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