Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redis-promise-lock

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-promise-lock

Simple promise-based redis lock. No bells, no whistles.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Redis Promise Lock

locks stuff until you unlock it. works with redis 4.x. promise based. simple.

When creating an instance, you can pass an options object as the second argument with the following properties:

  • retryLimit: number number of times lock is trying to be set before bailing out (default: 10)
  • retryDelay: number amount of time in ms to wait between retries (default: 100)
  • ttl: number ttl of the lock to be set in redis before its removed by redis itself in seconds, if set to 0, lock wont have a ttl (default: 3)

Those can also be overwritten in the acquireLock function.

Example Usage

import { createClient } from 'redis'
import { Lock } from './src/lock'

const client = createClient({
  url: 'redis://127.0.0.1:6379'
})

;(async () => {
  await client.connect()
  const lockerRoom = new Lock(client)

  await lockerRoom.acquireLock('myawesomelock')
  // ... do some stuff while the lock is active
  await lockerRoom.releaseLock('myawesomelock')

})()

Keywords

FAQs

Package last updated on 17 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc