node-redlock

A node.js redlock implementation for distributed, highly-available redis locks (by mike-marcacci)

Node-redlock Alternatives

Similar projects and alternatives to node-redlock based on common topics and language

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better node-redlock alternative or higher similarity.

node-redlock reviews and mentions

Posts with mentions or reviews of node-redlock. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-02-28.
  • Build an Idempotent API in Node.js with Redis
    2 projects | dev.to | 28 Feb 2024
    async function create(req, res) { let lock; try { // Try to acquire the lock lock = await service.urlService.acquireLock( "URL:CREATE:ExclusiveLock", 100 ); const { longURL } = req.body; // Check if the mapping already exists const mapping = await service.urlService.findByLongURL(longURL); if (mapping) { return res.status(HTTP_STATUS_CODES.SUCCESS).json({ status: true, message: "Short slug created successfully", data: { slug: mapping.slug }, }); } // New long URL, generate a new and unique slug const slug = service.urlService.generateNewSlug(); // save short URL <> long URL mapping to the database await service.urlService.saveToDB(slug, longURL); // Return the newly generated short slug return res.status(HTTP_STATUS_CODES.SUCCESS).json({ status: true, message: "Short slug created successfully", data: { slug }, }); } catch (err) { return res.status(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR).json({ status: false, message: "Could not create short slug", error: err, }); } finally { /** * Manually release the lock when the operation is complete * * NOTE: Redlock's release method is not a no-op, it throws an error if you try to release an already expired lock ([more here](https://github.com/mike-marcacci/node-redlock/issues/168#issuecomment-1165700540)). Setting a small TTL usually triggers this unexpected behavior. * As a workaround, we're ignoring the errors from lock.release() */ if (lock) await lock.release().catch(() => {}); } }
  • Advanced caching mechanisms using distributed locks and async pub/sub systems.
    1 project | dev.to | 17 Aug 2022
    Example: The following example uses Node.js npm module Redlock, which implements Redlock. Redlock is available as a package in many languages.

Stats

Basic node-redlock repo stats
2
1,729
3.7
3 months ago

mike-marcacci/node-redlock is an open source project licensed under MIT License which is an OSI approved license.

The primary programming language of node-redlock is TypeScript.


Sponsored
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com