redisstarter

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BloomCmd added in v0.1.1

func BloomCmd() *cmdBloom

func HashCmd

func HashCmd() *cmdHash

func KeyCmd

func KeyCmd() *cmdKey

func ListCmd added in v0.1.4

func ListCmd() *cmdList

func LockWithDeadline

func LockWithDeadline(ctx context.Context, key RedisKey, retryDeadline time.Time, retryInterval int, executable func(), keyAppend ...interface{}) (error, <-chan struct{})

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

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

func LockWithMaxRetry

func LockWithMaxRetry(ctx context.Context, key RedisKey, retryMax, retryInterval int, executable func(), keyAppend ...interface{}) (error, <-chan struct{})

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

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

func RawLockerClient

func RawLockerClient() *redislock.Client

RawLockerClient 获取原始RedisLockerClient进行操作

func RawRedisClient

func RawRedisClient() redis.UniversalClient

RawRedisClient 获取原始RedisClient进行操作

func SetCmd

func SetCmd() *cmdSet

func SortedSetCmd added in v0.1.4

func SortedSetCmd() *cmdSortedSet

func StringCmd

func StringCmd() *cmdString

func TopicCmd

func TopicCmd() *cmdTopic

func TryLock

func TryLock(key RedisKey, executable func(), keyAppend ...interface{}) (error, <-chan struct{})

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

func TryLockWithContext

func TryLockWithContext(ctx context.Context, key RedisKey, executable func(), keyAppend ...interface{}) (error, <-chan struct{})

TryLockWithContext 尝试获取锁并执行executable函数

Types

type BloomInfo added in v0.1.1

type BloomInfo struct {
	// 初始容量
	Capacity int64
	// 底层大小bit
	Size int64
	// 分片数量
	NumberOfFilters int64
	// 已插入总元素
	NumberOfItemsInserted int64
	// 拓展速率
	ExpansionRate int64
}

type Locker added in v0.1.6

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

func TryAndGetLocker added in v0.1.6

func TryAndGetLocker(key RedisKey, keyAppend ...interface{}) (*Locker, error)

TryAndGetLocker 尝试获取锁并返回Locker

func TryAndGetLockerWithContext added in v0.1.6

func TryAndGetLockerWithContext(ctx context.Context, key RedisKey, keyAppend ...interface{}) (*Locker, error)

TryAndGetLockerWithContext 尝试获取锁并返回Locker

func (*Locker) RawLocker added in v0.1.6

func (l *Locker) RawLocker() *redislock.Lock

func (*Locker) Release added in v0.1.6

func (l *Locker) Release() error

func (*Locker) ReleaseWithCtx added in v0.1.6

func (l *Locker) ReleaseWithCtx(ctx context.Context) error

type RedisConfig added in v0.1.9

type RedisConfig struct {
	redis.UniversalOptions
	InitFunc func(instance redis.UniversalClient)
}

type RedisKey

type RedisKey struct {

	// 最终key值的格式化格式 将使用 fmt.Sprintf(key.KeyFormat, keyAppend) 进行处理
	KeyFormat string
	// Key 过期时间(如果可以设置) 当该RedisKey作用与Locker时,该时间指明了自动释放锁时间 如果为零值则会立即失败
	Expire time.Duration
}

func NewRedisKey added in v0.1.4

func NewRedisKey(keyFormat string, expire ...time.Duration) RedisKey

NewRedisKey 创建一个RedisKey keyFormat 最终key值的格式化格式 将使用 fmt.Sprintf(key.KeyFormat, keyAppend) 进行处理

func (RedisKey) RawKeyString added in v0.1.9

func (r RedisKey) RawKeyString(keyAppend ...interface{}) string

RawKeyString 获取原始key字符串

type RedisStarter

type RedisStarter struct {
	Config     RedisConfig
	LazyConfig func() RedisConfig

	RedisSetting *parent.Setting
	// contains filtered or unexported fields
}

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