Skip to content

perzy/locker-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

locker-redis

NPM Version

Installation

$ npm install locker-redis
$ npm install ioredis

API

var RedisLocker = require('locker-redis');
var LockerTimeoutError = require('locker-redis').LockerTimeoutError;

RedisLocker(name,options)

RedisLocker class

var lockerName = 'user:100:account';
var options = {};
var redisLocker = new RedisLocker(lockerName, options);

RedisLocker#acquire(function next(){})

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

redisLocker.acquire(function (err, release) {
  if (err) {
    return callback(new Error());
  }
  
  // release();  You can call release function here to exec redis locker release.
  callback(null);
});

RedisLocker#release(function next(){})

Release this redisLocker

redisLocker.release();

Use generator version for koa

co-redis-locker

License

MIT

About

locker by redis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published