modulepackage
0.0.0-20200730142023-52ab6f614d78
Repository: https://github.com/dineshgowda24/redislock.git
Documentation: pkg.go.dev
# README
redislock
Simplified distributed locking implementation using Redis. For more information, please see examples.
Motivation
I came across a concurrency issue when multiple clients were accessing single redis instance. So I wanted a primitive locking solution, but redis did not have one implemented. So started looking for open source libraries and found redislock very well written and effective library. But it still did not solve my problem as I was using redigo client but the package used go-redis. Although redigo
had redsync
, I wanted a much more simpler one and so with redislock
.
Features
- Simple and easy to use interface.
- Plug in any redis client of your choice by implementing the
RedisClient
interface. - Simple but effective locking for single redis instance.
Examples
Check out examples in for garyburd
and go-redis
clients.
Documentation
Full documentation is available on GoDoc
Contribution
Feel free to send a PR.
# Packages
No description provided by the author
# Functions
ExponentialBackoff strategy is an optimization strategy with a retry time of 2**n milliseconds (n means number of times).
LimitRetry limits the number of retries to max attempts.
LinearBackoff allows retries regularly with customized intervals.
// New creates a new Client instance with a custom namespace.
NoRetry acquire the lock only once.
Obtain is a short-cut for New(...).Obtain(...).
# Constants
lua scripts which should be loaded to redis client when implementing RedisClient interface.
lua scripts which should be loaded to redis client when implementing RedisClient interface.
lua scripts which should be loaded to redis client when implementing RedisClient interface.
# Variables
ErrLockNotHeld is returned when trying to release an inactive lock.
ErrNotObtained is returned when a lock cannot be obtained.
# Interfaces
Implement the interface with which every redis client you wish to use.
RetryStrategy allows to customise the lock retry strategy.