do-with-redis-lock

3.0.2 • Public • Published

do-with-redis-lock

usage

redisConn = {
  port: 9000,
  host: "...",
  auth: "...",
  db: 1 #optional 
}
doWithLock = require("do-with-redis-lock")(redisConn)
 
action = ->
  request.getAsync(...) # something that returns a Promise 
 
doWithLock(actionkey).then (result) ->
  # continue... 

If a concurrency problem appears, the Promise is rejected with:

{
  statusCode: 503,
  body: {
    code: "concurrency_conflict",
    message: "Somebody is doing this at the same time at you"
  }
}

migration

1.x users

  • In 2.x, the Promise's rejection reason isn't "concurrency_conflict" anymore. See above.

2.x users

  • In 3.x, the connection credentials are no longer environment variables. They are passed by parameters instead. See above.

Readme

Keywords

none

Package Sidebar

Install

npm i do-with-redis-lock

Weekly Downloads

118

Version

3.0.2

License

none

Unpacked Size

4.32 kB

Total Files

5

Last publish

Collaborators

  • gastonprieto18
  • rodri042