redisutil

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 2 Imported by: 0

README

go redis util

go redis connection helper go simple redis locker (with holder)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearLocks

func ClearLocks(client *redis.Client, holder string) error

清除指定holder的拥有的所有锁

func ReleaseLock

func ReleaseLock(client *redis.Client, key string, holder string) (bool, error)

释放锁

Types

type RedisLock

type RedisLock struct {
	Key           string //锁key
	Holder        string //锁拥有者
	ExpireSeconds int64  //锁过期时间(秒)
}

redis 锁

func AcquireLock

func AcquireLock(client *redis.Client, key string, holder string) (*RedisLock, error)

获取锁(永不过期)

func AcquireLockWithExpire

func AcquireLockWithExpire(client *redis.Client, key string, holder string, expireSeconds int64) (*RedisLock, error)

获取锁(带过期时间)

func (*RedisLock) ReleaseSelf

func (lock *RedisLock) ReleaseSelf(client *redis.Client) (bool, error)

释放

Jump to

Keyboard shortcuts

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