locker

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorLockOccupied = errors.New("lock is occupied")
)

Functions

func Key added in v1.0.4

func Key(k string, ks ...string) string

Types

type ILocker

type ILocker interface {
	// Lock 获得锁
	Lock(key string) error
	// UnLock 释放锁
	UnLock(key string) error
}

ILocker 锁约定

func NewDistributedRedisLock

func NewDistributedRedisLock(client *redis.Client) ILocker

NewDistributedRedisLock 创建分布式 redis 锁

type ILockerTimeout

type ILockerTimeout interface {
	// SetTimeout 设置超时时间
	SetTimeout(expire time.Duration) error
}

ILockerTimeout 锁超时约定

Jump to

Keyboard shortcuts

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