sync

package module
v0.0.0-...-d98589b Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

sync

distributed sync lock

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockFailed   = errors.New("lock failed")
	ErrUnlockFailed = errors.New("unlock failed")
)

Functions

This section is empty.

Types

type Mutexer

type Mutexer interface {
	Lock() (err error)
	Unlock() (err error)
}

type OptionFunc

type OptionFunc func(o *Options)

func KeyPrefix

func KeyPrefix(prefix string) OptionFunc

func LockTimeout

func LockTimeout(duration time.Duration) OptionFunc

func WaitRetry

func WaitRetry(duration time.Duration) OptionFunc

type Options

type Options struct {
	KeyPrefix   string
	LockTimeout time.Duration
	WaitRetry   time.Duration
}

type RedisSync

type RedisSync struct {
	Opt   *Options
	Redis *redis.Client
}

func NewRedisSync

func NewRedisSync(client *redis.Client, opts ...OptionFunc) *RedisSync

func (*RedisSync) NewMutex

func (s *RedisSync) NewMutex(key string, opts ...OptionFunc) Mutexer

Jump to

Keyboard shortcuts

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