redislock

package
v0.0.0-...-3b4d626 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package redislock implements locker based on Redis server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock provides redis key locker

func New

func New(client redis.Cmdable, defaultLifetime time.Duration) *Lock

New returns redis Lock for redis client

func NewByURL

func NewByURL(connectURL string, defaultLifetime time.Duration) (*Lock, error)

NewByURL returns redis Lock object or error Example "redis://host1:6379,host2:6379/12"

func (*Lock) Expire

func (mr *Lock) Expire(key interface{}, lifetime ...time.Duration) error

Expire TTL of existing lock

func (*Lock) IsLocked

func (mr *Lock) IsLocked(key interface{}) bool

IsLocked in the redis server

func (*Lock) TryLock

func (mr *Lock) TryLock(key interface{}, lifetime ...time.Duration) error

TryLock message as processing

func (*Lock) Unlock

func (mr *Lock) Unlock(key interface{}) error

Unlock message as processing

Jump to

Keyboard shortcuts

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