
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
RedLock is a TypeScript library for acquiring and releasing locks using Redis, designed for use in Node.js applications.
RedLock is a TypeScript library for acquiring and releasing locks using Redis, designed for use in Node.js applications.
Install the RedLock library using npm:
npm install redlock-js
To use RedLock in your Node.js application, follow these steps:
import RedLock, { LockOptions } from 'redlock-js';
const lockOptions: LockOptions = {
redis: {
host: 'localhost',
port: 6379,
},
key: 'my-lock',
interval: 100, // Optional, specify the retry interval in milliseconds
};
const redlock = new RedLock(lockOptions);
// Acquire a lock
await redlock.lock();
// Perform your critical section of code here
// Release the lock when done
await redlock.release();
You can configure RedLock by providing options when creating an instance:
redis
: Redis connection options.cluster
: If you're using a Redis cluster, provide cluster configuration.key
: The unique key for your lock.interval
(default: 100): Retry interval in milliseconds when attempting to acquire the lock.expire
(default: 300): Expiration time in seconds for the lock key. Setting an expiration time allows you to automatically release the lock after a certain duration, effectively locking a resource without needing an explicit release operation.RedLock includes an automatic cleanup function that can be used to clean up leftover lock keys. You can use the clean
method to scan and delete expired lock keys from the Redis database.
await redlock.clean();
By calling the clean
method, you can ensure that expired lock keys are removed, preventing potential issues with stale locks.
You can also check whether a lock is currently active using the isLocking
method:
const lockingStatus = await redlock.isLocking();
console.log(`Is locking: ${lockingStatus}`);
The isLocking
method returns a boolean indicating whether the lock is currently active or not.
To properly release resources and end the Redis connection, use the end
method:
await redlock.end();
Calling the end
method will gracefully close the connection to the Redis server. Additionally, when you call the release
method, the lock will be released and the associated Redis connection will be closed.
FAQs
RedLock is a TypeScript library for acquiring and releasing locks using Redis, designed for use in Node.js applications.
The npm package redlock-js receives a total of 1 weekly downloads. As such, redlock-js popularity was classified as not popular.
We found that redlock-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.