redisstarter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashCmd

func HashCmd() *cmdHash

func KeyCmd

func KeyCmd() *cmdKey

func LockWithDeadline

func LockWithDeadline(ctx context.Context, key string, lockTtl time.Duration, retryDeadline time.Time, retryInterval int, executable func()) error

LockWithDeadline 持续尝试获取锁 request lockTtl 获得锁之后的持续时长(超时自动释放)

retryDeadline 重试持续时间
retryInterval 重试间隔(millisecond)

func LockWithMaxRetry

func LockWithMaxRetry(ctx context.Context, key string, lockTtl time.Duration, retryMax, retryInterval int, executable func()) error

LockWithMaxRetry 持续尝试获取锁 request lockTtl 获得锁之后的持续时长(超时自动释放)

retryMax 尝试获取锁最大重试次数
intervalMil 重试间隔(millisecond)

func OriginKeyString

func OriginKeyString(keyFormat string, keyAppend ...interface{}) string

func QueueCmd

func QueueCmd() *cmdQueue

func RawLockerClient

func RawLockerClient() *redislock.Client

RawLockerClient 获取原始RedisLockerClient进行操作

func RawRedisClient

func RawRedisClient() redis.UniversalClient

RawRedisClient 获取原始RedisClient进行操作

func SetCmd

func SetCmd() *cmdSet

func StringCmd

func StringCmd() *cmdString

func TopicCmd

func TopicCmd() *cmdTopic

func TryLock

func TryLock(key string, lockTtl time.Duration, executable func()) error

TryLock 取锁并执行executable函数 request lockTtl: 获得锁之后的持续时长(超时自动释放)

func TryLockWithContext

func TryLockWithContext(ctx context.Context, key string, lockTtl time.Duration, executable func()) error

TryLockWithContext 取锁并执行executable函数

Types

type RedisKey

type RedisKey struct {

	// 最终key值的格式化格式 将使用 fmt.Sprintf(key.KeyFormat, keyAppend) 进行处理
	KeyFormat string
	Expire    time.Duration
}

type RedisStarter

type RedisStarter struct {
	RedisConfig     redis.UniversalOptions
	LazyRedisConfig func() redis.UniversalOptions

	RedisSetting *parent.Setting
	InitFunc     func(instance redis.UniversalClient)
}

func (*RedisStarter) Setting

func (r *RedisStarter) Setting() *parent.Setting

func (*RedisStarter) Start

func (r *RedisStarter) Start() (interface{}, error)

func (*RedisStarter) Stop

func (r *RedisStarter) Stop(maxWaitTime time.Duration) (gracefully, stopped bool, err error)

Jump to

Keyboard shortcuts

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