redislock

package
v0.0.0-...-d0d5b52 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// these errors describes a result of a record lock
	Ok             = RedisLockError(nil)
	AlreadyLocked  = RedisLockError(errors.New("a key is already locked"))
	Uninitialized  = RedisLockError(errors.New("locker or redis client is not initialized"))
	EmptyKey       = RedisLockError(errors.New("key to lock is empty"))
	UnlockRequired = RedisLockError(errors.New("locker is already locked another key"))
)

Functions

This section is empty.

Types

type RedisLock

type RedisLock interface {
	Lock(ctx context.Context, key string, ttl time.Duration) RedisLockError
	ObtainLock(
		ctx context.Context,
		key string,
		ttl time.Duration,
		timeout time.Duration,
		loopPeriod time.Duration,
	) RedisLockError
	Unlock() RedisLockError
}

RedisLock describes a locker interface.

func NewRedisLocker

func NewRedisLocker(c *redis.Client) RedisLock

type RedisLockError

type RedisLockError error

Jump to

Keyboard shortcuts

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