pd-redis-lock

A pessimistic lock implementation based on Redis


Keywords
redis, pessimistic, lock
License
MIT
Install
npm install pd-redis-lock@0.1.2

Documentation

pd-redis-lock

A pessimistic lock implementation based on Redis

var lock = require('pd-redis-lock');
lock('mylock', function(){
   //do my stuff
   //when it is done it will be unlocked
   //if there is asynchronous work, it can be wrapped in a q.Promise and returned
   return q.Promise(function(resolve){
      resolve(...)
   }).then(...);
}, 1000).then(function(){
   //do stuff after it is unlocked...
});