redis_utils

package
v0.0.0-...-f0933ba Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKey

func CreateKey(keyParts ...string) string

CreateKey joins key parts with the standard Redis key separator.

func GetLockKey

func GetLockKey(key string) string

func SameSlot

func SameSlot(key string) string

SameSlot wraps a key in curly braces to force Redis Cluster hash slot co-location. This is needed to use Lua scripts, MGET, and transactions across multiple keys.

func SetupInstance

func SetupInstance(t *testing.T) redis.UniversalClient

Types

type Lock

type Lock interface {
	Release(ctx context.Context) error
}

Lock abstracts a held distributed lock.

type Locker

type Locker interface {
	Obtain(ctx context.Context, key string, ttl time.Duration, opts *redislock.Options) (Lock, error)
}

Locker abstracts distributed lock acquisition.

type NoopLock

type NoopLock struct{}

NoopLock is a lock that does nothing on release.

func (NoopLock) Release

func (NoopLock) Release(context.Context) error

type NoopLocker

type NoopLocker struct{}

NoopLocker always succeeds without acquiring any lock.

func (NoopLocker) Obtain

type RedisLocker

type RedisLocker struct {
	Client *redislock.Client
}

RedisLocker wraps redislock.Client.

func (*RedisLocker) Obtain

func (l *RedisLocker) Obtain(ctx context.Context, key string, ttl time.Duration, opts *redislock.Options) (Lock, error)

Jump to

Keyboard shortcuts

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