idempotency-redis (v1.5.1) is a Node.js library that guarantees idempotent execution of operations using Redis for shared state and distributed locking. It ensures that for a given idempotency key, only one execution occurs; concurrent calls with the same key replay the cached result (including errors). Built on ioredis and using Redlock for distributed mutex, it differentiates from simple Redis-based idempotency by handling concurrent requests, caching failures, and providing custom error handling callbacks. Released as stable (since v1), with peer dependency ioredis 5.x.
npm install idempotency-redisNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating an executor, running an idempotent operation with a key, and demonstrating that duplicate calls return the cached result instead of executing again.
Replace colons with hyphens or underscores in namespace and key values.
Upgrade Node.js to one of the supported major versions.
N/A
Pass shouldIgnoreError to executor constructor: new IdempotentExecutor(redis, { shouldIgnoreError: (err) => true })Catch IdempotentExecutorCriticalError and handle appropriately (e.g., implement fallback).
Use dynamic import: const { IdempotentExecutor } = await import('idempotency-redis');Use named import: import { IdempotentExecutor } from 'idempotency-redis';Run: npm install ioredis