redis

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisLock

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

A RedisLock is a redis lock.

func NewRedisLock

func NewRedisLock(store *redigo.Conn, key string, value string) *RedisLock

NewRedisLock returns a RedisLock.

func (*RedisLock) Lock

func (rl *RedisLock) Lock() (bool, error)

Lock acquires the lock.

func (*RedisLock) LockCtx

func (rl *RedisLock) LockCtx(ctx *gin.Context) (bool, error)

LockCtx acquires the lock with the given ctx.

func (*RedisLock) SetExpire

func (rl *RedisLock) SetExpire(seconds int)

SetExpire sets the expiration. 需要注意的是需要在Acquire()之前调用 不然默认为500ms自动释放

func (*RedisLock) Unlock

func (rl *RedisLock) Unlock() (bool, error)

Unlock releases the lock.

func (*RedisLock) UnlockCtx

func (rl *RedisLock) UnlockCtx(ctx *gin.Context) (bool, error)

UnlockCtx releases the lock with the given ctx.

Jump to

Keyboard shortcuts

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