redis_mutex

package
v0.0.0-...-b1e3f6c Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMutexTTL      = time.Second * 5
	DefaultCheckInterval = time.Millisecond * 20
)
View Source
const (
	WLockKeyPrefix string = "w-lock:"
	RLockKeyPrefix string = "r-lock:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisMutex

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

func NewRedisMutex

func NewRedisMutex(client *redis.Client) *RedisMutex

func (*RedisMutex) Lock

func (r *RedisMutex) Lock(ctx context.Context, key string) error

func (*RedisMutex) TryLock

func (r *RedisMutex) TryLock(ctx context.Context, key string) (bool, error)

func (*RedisMutex) Unlock

func (r *RedisMutex) Unlock(ctx context.Context, key string) error

type RedisRWMutex

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

func NewRedisRWMutex

func NewRedisRWMutex(client *redis.Client) *RedisRWMutex

func (*RedisRWMutex) Lock

func (r *RedisRWMutex) Lock(ctx context.Context, key string) error

func (*RedisRWMutex) RLock

func (r *RedisRWMutex) RLock(ctx context.Context, key string) error

func (*RedisRWMutex) RUnlock

func (r *RedisRWMutex) RUnlock(ctx context.Context, key string) error

func (*RedisRWMutex) Unlock

func (r *RedisRWMutex) Unlock(ctx context.Context, key string) error

Jump to

Keyboard shortcuts

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