Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eknkc/lockredis
Simple locking utility on top of Redis
https://github.com/eknkc/lockredis
Last synced: 9 days ago
JSON representation
Simple locking utility on top of Redis
- Host: GitHub
- URL: https://github.com/eknkc/lockredis
- Owner: eknkc
- Created: 2014-02-13T23:28:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-01T22:55:31.000Z (over 10 years ago)
- Last Synced: 2024-12-17T01:32:33.532Z (17 days ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lockredis
Barebones locking utility for Redis. Uses the algorithm described in [Redis Documentation](http://redis.io/commands/SET).## install
npm install lockredis
## usage
```javascript
var lockredis = require('lockredis');
var locker = lockredis(redis.createClient());locker('lockname', {
timeout: 5000, // Time for a lock to expire on its own in milliseconds
retries: Infinity, // Number of retries in case the lock is already acquired
retryDelay: 250 // Time between retry attempts in milliseconds
}, function(err, done) {
if (err) {
// Lock could not be acquired for some reason.
}// do stuff...
done() // release lock
});
```## license
MIT