Documentation
¶
Overview ¶
Package redlock implements a simple mutex on a single redis instance, using a connection pool for performance and efficiency.
Note that this design does not guarantee correctness. It is lightweight and appropriate for use cases where two clients holding the same lock simultaneously is not a critical issue. It is possible, in cases of processes running overlong, or the redis node's failure, for more than one process to hold a given lock simultaneously. This should happen only very rarely, but it can happen.
Index ¶
- Variables
- type RedisConfig
- type Redlock
- func (rl *Redlock) Close() (err error)
- func (rl *Redlock) Lock(key string, timeout time.Duration) (acquired bool, err error)
- func (rl *Redlock) Renew(key string, timeout time.Duration) (renewed bool, err error)
- func (rl *Redlock) Unlock(key string) (err error)
- func (rl *Redlock) WaitLock(key string, timeout time.Duration, retryInterval time.Duration) (acquired bool, err error)
Constants ¶
This section is empty.
Variables ¶
var ConfigNotSetError string = "No redis config set."
Functions ¶
This section is empty.
Types ¶
type RedisConfig ¶
type Redlock ¶
type Redlock struct {
// contains filtered or unexported fields
}
func New ¶
func New(conf *RedisConfig) (rl *Redlock)
New returns a redlock instance. It is the consumer's responsibility to close the Redlock's connection pool via Close() if possible.
func (*Redlock) Lock ¶
Lock tries to acquire a lock on the given connection for the key via SETNX as discussed at http://redis.io/commands/setnx, returning true if successful. Timeout is given in milliseconds.
func (*Redlock) Renew ¶
Extend the time on a given lock - only to be called by lock's current holder or delegate