redislocker

package
v1.0.0-beta.26 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Default = StdConfig("default").Build()
)

Functions

func IsLocked

func IsLocked(ctx context.Context, key string) (bool, error)

func Lock

func Lock(ctx context.Context, key string, expire time.Duration) (bool, error)

func UnLock

func UnLock(ctx context.Context, key string) error

Types

type Config

type Config struct {
	Prefix string `config:"prefix" desc:"locker key prefix. if empty, auto prefix with format: ${serviceName}.locker.${key}."`
	Config string `config:"config" desc:"redis config path. eg: 'default' means use 'redis.default' config"`
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig(key string) *Config

func StdConfig

func StdConfig(key string) *Config

func (*Config) Build

func (c *Config) Build() locker.MutexLocker

func (*Config) Path

func (c *Config) Path() string

type Locker

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

Locker redis lock

func (*Locker) IsLocked

func (l *Locker) IsLocked(ctx context.Context, key string) (bool, error)

IsLocked return is is locked

func (*Locker) Lock

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

Lock key

func (*Locker) UnLock

func (l *Locker) UnLock(ctx context.Context, key string) error

UnLock unlock key

Jump to

Keyboard shortcuts

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