lockredis

1.0.0 • Public • Published

lockredis

Barebones locking utility for Redis. Uses the algorithm described in Redis Documentation.

install

npm install lockredis

usage

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

Package Sidebar

Install

npm i lockredis

Weekly Downloads

7

Version

1.0.0

License

MIT

Last publish

Collaborators

  • eknkc