redmutex

0.1.0 • Public • Published

redmutex

easy peasy locking using redis

Installation

npm install --save redmutex redis

Example

const redis = require('redis')
const redmutex = require('redmutex')

const client = redis.createClient()
const createMutex = redmutex(client)

// createMutex(name, ttl, callback)
createMutex('test', 10, (err, release) => {
    if (err) return console.log(err)
    setTimeout(() => {
        console.log('just finished doing some hard work!!!')
        release(() => client.quit())
    }, 7500)
})

Testing

Code is linted with eslint and tested with Jest. Run npm test to lint and run test suite.

License

Released under the terms of the 3-Clause BSD License. See LICENSE for more information.

Readme

Keywords

Package Sidebar

Install

npm i redmutex

Weekly Downloads

2

Version

0.1.0

License

BSDv3

Last publish

Collaborators

  • excitableaardvark