co-redis-locker
v0.1.0
Published
Distributed locker by redis
Downloads
2
Readme
co-redis-locker
Distributed cache locker by redis.
Install
$ npm install --save co-redis-locker
API
const RedisLocker = require('co-redis-locker');
const LockerTimeoutError = require('co-redis-locker').LockerTimeoutError;
RedisLocker(name,options)
RedisLocker class
const lockerName = 'user:100:account';
const options = {};
const redisLocker = new RedisLocker(lockerName, options);
RedisLocker#acquire()
Acquire redisLocker retry some times.If timeout then throw timeout error.
const locker = yield redisLocker.acquire();
RedisLocker#release()
Release this redisLocker
yield redisLocker.release();
RedisLocker#sleep()
Sync sleep wait function.