redisc

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnLockScript string = `
	if redis.call('GET', KEYS[1]) == ARGV[1] then
		return redis.call('DEL', KEYS[1])
	else 
		return 0 
	end
`
	KeepLockScript string = `
	if redis.call('GET', KEYS[1]) == ARGV[1] then
		return redis.call('PEXPIRE', KEYS[1], ARGV[2]) 
	else
		return 0 
	end
`
)

Variables

This section is empty.

Functions

func GetRedisPool

func GetRedisPool(conf *gofkConf.RedisConfig) *redis.Pool

func GetRedisPoolMq

func GetRedisPoolMq(conf *gofkConf.RedisConfig) *redis.Pool

func Incrementing

func Incrementing(key string) int64

Types

type LockOptionFunc

type LockOptionFunc func(option *lockOption)

func WithLockTTL

func WithLockTTL(lt time.Duration) LockOptionFunc

func WithRedisConf

func WithRedisConf(conf *gofkConf.RedisConfig) LockOptionFunc

func WithRedisPool

func WithRedisPool(pool *redis.Pool) LockOptionFunc

func WithWaitCAS

func WithWaitCAS(wt time.Duration) LockOptionFunc

type LockerInter

type LockerInter interface {
	SetKey(string) LockerInter
	Lock() error
	UnLock() (bool, error)
	WaitCAS() error
}

func NewLock

func NewLock(conf *gofkConf.RedisConfig, opts ...LockOptionFunc) LockerInter

Jump to

Keyboard shortcuts

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