1.2.0 • Published 6 years ago

elock v1.2.0

Weekly downloads
78
License
MIT
Repository
github
Last release
6 years ago

node-elock

Greenkeeper badge

Easy use distributed redis lock implementation

Installation

npm install elock --save

Usage

// Init redis client
const Redis = require('ioredis');
const redisClient = new Redis();

// Init ELock
const ELock = require('elock');
const lock = new ELock({ redis: redisClient });

// Acquire Lock
lock.acquire('key').then(() => {
  // do someting when get lock

  // release after done
  return lock.release('key')
}).catch((err) => {
  // err when can't get lock
})

// Get lock
lock.get('key').then((res) => {
  if(res === null) return '' // null is get lock fail
  // do someting when get lock
})

// Check is Locked
lock.locked('key').then((locked) => {
  // locked is a boolean
})
1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago