npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nestjs-redisx/dedup

v1.14.0

Published

Event deduplication and distributed debounce plugin for NestJS RedisX — first-wins markers with TTL windows, @Dedupe, and trailing debounce

Readme

@nestjs-redisx/dedup

Event deduplication and distributed debounce plugin for NestJS RedisX — run webhooks, queue messages, and user actions once per window across the fleet, with first-wins TTL markers and a trailing debounce.

Why

Webhook providers redeliver. Queues are at-least-once. Users double-click. A lightweight "have I seen this key in the last N seconds?" check — atomic across every instance — removes the whole class of duplicate side effects without the weight of full request idempotency.

  • First-wins markers — SET NX PX under the hood: exactly one winner per key per window, fleet-wide.
  • Failures don't burn the window — when the first execution throws, its marker is released (CAS on the owner token), so a retry isn't locked out until the TTL.
  • Distributed trailing debounce — the function runs once the key goes quiet, on the instance that made the LAST call.
  • @Dedupe — proxy-based decorator for any @Injectable method with {n} key templates.
  • errorPolicy — gates fail open (default, duplicates possible during an outage) or closed (skip + throw); manual APIs are always strict.

Deduplication here is a lightweight marker — nothing is stored or replayed. For request-grade idempotency with fingerprints and response replay, use @nestjs-redisx/idempotency.

Install

npm install @nestjs-redisx/core @nestjs-redisx/dedup ioredis

Quick start

import { Module, Injectable } from '@nestjs/common';
import { RedisModule } from '@nestjs-redisx/core';
import { DedupPlugin, Dedupe } from '@nestjs-redisx/dedup';

@Module({
  imports: [
    RedisModule.forRoot({
      clients: { type: 'single', host: 'localhost', port: 6379 },
      plugins: [new DedupPlugin({ defaultWindow: 60_000 })],
    }),
  ],
})
export class AppModule {}

@Injectable()
export class WebhookService {
  // Each Stripe event id is handled once per 5 minutes, fleet-wide
  @Dedupe({ key: 'stripe:{0}', window: 300_000 })
  async handleEvent(eventId: string, payload: unknown) {
    // ...
  }
}

Service API:

import { Inject, Injectable } from '@nestjs/common';
import { DEDUP_SERVICE, type IDedupService } from '@nestjs-redisx/dedup';

@Injectable()
export class EventsService {
  constructor(@Inject(DEDUP_SERVICE) private readonly dedup: IDedupService) {}

  async onOrderCreated(orderId: string) {
    // exactly one confirmation email per order per window
    await this.dedup.dedupe(`order-created:${orderId}`, () => this.sendConfirmation(orderId));
  }

  async onProductChanged() {
    // rebuild the index once per quiet minute, on the last-calling instance
    await this.dedup.debounce('reindex:products', () => this.rebuildIndex(), { window: 60_000 });
  }
}

Documentation

Full reference: https://nestjs-redisx.dev/en/reference/dedup/

License

MIT