Socket
Socket
Sign inDemoInstall

@abeai/node-redlock

Package Overview
Dependencies
1
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @abeai/node-redlock

Wrapper for node-redlock.


Version published
Maintainers
2
Install size
39.1 kB
Created

Readme

Source

Wrapper for node-redlock.

Overview

This package provides a pragmatic interface on top of node-redlock.

Installation

npm install @abeai/node-redlock --save

Instantiation

const Redlock = require('@abeai/node-redlock');
const redis = require('@abeai/node-redlock');

redis.init(host, options);

const redlock = new Redlock(redis.client());

redlock.lock('lockkey', 1000, () => {
    ...
});

Interface

Redlock(redisClients[, options])

Creates a new redlock instance.

redisClients can be a single Redis client or an array of Redis clients.

Options
defaultTtl

Default TTL in ms which should be used if ttl is obmitted in redlock.lock call.

driftFactor

The expected clock drift in ms. Default: 0.01

For more details see http://redis.io/topics/distlock.

retryCount

The max number of times Redlock will attempt to lock a resource before erroring. Default: 300

retryDelay

The time in ms between attempts. Default: 50

retryJitter

The max time in ms randomly added to retries to improve performance under high contention. Default: 50

For more details see https://www.awsarchitectureblog.com/2015/03/backoff.html.

redlock.lock(resource[, ttl], fn)

Locks a given resource using the Redlock algorithm. Accepts a resource string, TTL of milliseconds that the lock should be held, and a function that should be executed while the resource is locked.

If ttl is obmitted, options.defaultTtl is used instead.

Keywords

FAQs

Last updated on 06 Jan 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc