locker-redis

simple locker by redis

Usage no npm install needed!

<script type="module">
  import lockerRedis from 'https://cdn.skypack.dev/locker-redis';
</script>

README

locker-redis

[![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url]

Installation

$ npm install locker-redis
$ npm install ioredis

API

var RedisLocker = require('locker-redis');
var LockerTimeoutError = require('locker-redis').LockerTimeoutError;
var redisLocker = new RedisLocker(lockerName, options);

RedisLocker(name,options)

RedisLocker class

RedisLocker#acquire(function next(){})

Acquire redisLocker retry some times.If timeout then throw error.

redisLocker.acquire(function (err) {
  if (err) {
    return callback(new Error());
  }
  callback(null);
});

RedisLocker#release(function next(){})

Release this redisLocker

redisLocker.release();

License

MIT