rlq

redis-lock-q

promisified redis-lock

Showing:

Popularity

Downloads/wk

8

GitHub Stars

0

Maintenance

Last Commit

7yrs ago

Contributors

1

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

redis-lock-q

A promisified version of redis-lock, which implements a locking primitive using redis in node.js.

Example

Take the redis-lock example

var client = require("redis").createClient(),
    lock = require("redis-lock")(client);

lock("myLock", function(done) {
  // No one else will be able to get a lock on 'myLock' until you call done()
  done(function () {
    // You can optionally call done with a callback,
    // which is called when the lock is released
  });
});

The redis-lock-q version looks something like this

lock("myLock", function() {
  // No one else will be able to get a lock on 'myLock' until your return value resolves/rejects
  // You can return non-promise values, but they will be treated as promises resolved with the value
  return q.resolve().delay(1000); // in a second, the lock will be released
}).fin(function() {
  // The lock has been released
});

lock itself now returns a promise, which is just a proxy for the resolved/rejected promise that your function returned.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial