lock

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBLock

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

DBLock 基于DB的分布式锁(无Redis时用)

func NewDBLock

func NewDBLock(db *gorm.DB) *DBLock

func (*DBLock) Lock

func (l *DBLock) Lock(ctx context.Context, key string, timeout time.Duration) (bool, func(), error)

Lock 基于DB的行锁实现

type DistributedLock

type DistributedLock interface {
	// Lock 抢占锁,返回:是否成功、解锁函数、错误
	Lock(ctx context.Context, key string, timeout time.Duration) (bool, func(), error)
}

DistributedLock 分布式锁接口(适配Redis/DB)。 Redis 实现见可选子包 pkg/lock/redislock;内存实现见 runtime/internal。

Directories

Path Synopsis
Package redislock provides a Redsync (Redis) backed lock.DistributedLock.
Package redislock provides a Redsync (Redis) backed lock.DistributedLock.

Jump to

Keyboard shortcuts

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