lock

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRetryTimes = uint8(20)
	DefaultRetryDelay = time.Millisecond * 300
	DefaultLockTTL    = time.Second * 2
)

Variables

This section is empty.

Functions

func Simple

func Simple(key string, handler Handler, options ...Option) error

Types

type Handler

type Handler func() error

type Option

type Option func(*option)

func WithLockTTL

func WithLockTTL(ttl time.Duration) Option

func WithRedisClient

func WithRedisClient(client RedisClient) Option

func WithRetryDelay

func WithRetryDelay(delay time.Duration) Option

func WithRetryTimes

func WithRetryTimes(times uint8) Option

type RedisClient

type RedisClient interface {
	TTL(key string) *redis.DurationCmd
	Del(keys ...string) *redis.IntCmd
	SetNX(key string, value interface{}, expiration time.Duration) *redis.BoolCmd
}

Jump to

Keyboard shortcuts

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