redis

package
v0.4.14 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCouldNotLock    = errors.New("lock could not be obtained")
	ErrCouldNotRelease = errors.New("lock could not be released")
)

Functions

This section is empty.

Types

type Lock

type Lock struct {
	Name string
	// contains filtered or unexported fields
}

func NewLock

func NewLock(name string, opts ...LockOption) *Lock

func (*Lock) Acquire

func (l *Lock) Acquire(ctx context.Context) (bool, error)

func (*Lock) AcquireAndKeepUp

func (l *Lock) AcquireAndKeepUp(ctx context.Context) (context.Context, context.CancelFunc, error)

AcquireAndKeepUp will acquire a lock, and keep it up constantly until cancel is called, the returned context is a lock context and is detached from the parent context, meaning that any cancellation/timeout on the parent context does not affect this lock context.

func (*Lock) AcquireWait

func (l *Lock) AcquireWait(ctx context.Context) error

func (*Lock) Release

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

type LockOption

type LockOption func(l *Lock)

func SetClient

func SetClient(client *redislock.Client) LockOption

func SetTTL

func SetTTL(ttl time.Duration) LockOption

Jump to

Keyboard shortcuts

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