locklock-redis

0.1.3 • Public • Published

locklock

License: MIT Build Status: npm

A simple global locking/unlocking mechanism using redis

how to install

npm i locklock-redis

how to use

  • The interface contains two main functions acquireLock, releaseLock.
  • to use locking you need to have an intialized redis client and choose a string to be used for locking on redis
  • to try and acquire the lock on certain key:
const res = await locklock.acquireLock(client, testString);// will return 1 if lock is acquired successfully
// will return 0 if already locked by someone else
  • to unlock a key after you are done executing critical section:
let res = await locklock.releaseLock(client, testString);// will return true asserting that your unlock process is successfull

Package Sidebar

Install

npm i locklock-redis

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

8 kB

Total Files

8

Last publish

Collaborators

  • kareem_