redislock

package
v0.0.0-...-2c78e32 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DelayFunc

type DelayFunc func(tries int) time.Duration

A DelayFunc is used to decide the amount of time to wait between retries.

type LockGenerator

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

LockGenerator 分布式锁生成器

func NewLockGenerator

func NewLockGenerator(clients []*redis.Client) *LockGenerator

NewLockGenerator 基于多个redis客户端生成NewLockGenerator实例

func (*LockGenerator) NewMutex

func (g *LockGenerator) NewMutex(name string, options ...Option) *Mutex

NewMutex returns a new distributed mutex with given name.

type Mutex

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

func (*Mutex) Extend

func (m *Mutex) Extend() bool

func (*Mutex) Lock

func (m *Mutex) Lock() error

func (*Mutex) Unlock

func (m *Mutex) Unlock() bool

type Option

type Option interface {
	Apply(*Mutex)
}

Option

func SetDriftFactor

func SetDriftFactor(factor float64) Option

SetDriftFactor can be used to set the clock drift factor.

func SetExpiry

func SetExpiry(expiry time.Duration) Option

SetExpiry can be used to set the expiry of a mutex to the given value.

func SetGenValueFunc

func SetGenValueFunc(genValueFunc func() (string, error)) Option

SetGenValueFunc can be used to set the custom value generator.

func SetRetryDelayFunc

func SetRetryDelayFunc(delayFunc DelayFunc) Option

SetRetryDelayFunc can be used to override default delay behavior.

func SetTries

func SetTries(tries int) Option

SetTries can be used to set the number of times lock acquire is attempted.

type OptionFunc

type OptionFunc func(*Mutex)

OptionFunc is a function that configures a mutex.

func (OptionFunc) Apply

func (f OptionFunc) Apply(mutex *Mutex)

Apply calls f(mutex)

Jump to

Keyboard shortcuts

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