0.1.0 • Published 6 years ago

redmutex v0.1.0

Weekly downloads
4
License
BSDv3
Repository
github
Last release
6 years ago

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.