Soenneker.Deduplication.SlidingWindow.Registry 4.0.126

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Deduplication.SlidingWindow.Registry --version 4.0.126
                    
NuGet\Install-Package Soenneker.Deduplication.SlidingWindow.Registry -Version 4.0.126
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Deduplication.SlidingWindow.Registry" Version="4.0.126" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Deduplication.SlidingWindow.Registry" Version="4.0.126" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Deduplication.SlidingWindow.Registry" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Deduplication.SlidingWindow.Registry --version 4.0.126
                    
#r "nuget: Soenneker.Deduplication.SlidingWindow.Registry, 4.0.126"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Deduplication.SlidingWindow.Registry@4.0.126
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Deduplication.SlidingWindow.Registry&version=4.0.126
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Deduplication.SlidingWindow.Registry&version=4.0.126
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Deduplication.SlidingWindow.Registry

A thread-safe registry that creates and reuses one in-memory sliding-window deduplicator per string key.

Installation

dotnet add package Soenneker.Deduplication.SlidingWindow.Registry

Registration

using Soenneker.Deduplication.SlidingWindow.Registry.Registrars;

services.AddSlidingWindowDedupeRegistryAsSingleton();

Singleton registration shares each key’s recent-history window across dependency-injection scopes. Use AddSlidingWindowDedupeRegistryAsScoped() only when each scope should have independent history.

Usage

using Soenneker.Deduplication.SlidingWindow.Abstract;
using Soenneker.Deduplication.SlidingWindow.Registry.Abstract;

public sealed class EventConsumer(ISlidingWindowDedupeRegistry registry)
{
    public async ValueTask<bool> ShouldProcess(string tenantId, string eventId, CancellationToken cancellationToken)
    {
        ISlidingWindowDedupe dedupe = await registry.Get(
            key: $"tenant:{tenantId}",
            window: TimeSpan.FromMinutes(10),
            rotationInterval: TimeSpan.FromSeconds(10),
            cancellationToken);

        return dedupe.TryMarkSeen(eventId);
    }
}

The first successful lookup creates the instance. Later calls for the same key return it even when they supply a different window or rotation interval, so keep those settings consistent.

Releasing inactive keys

Each registry key owns a set and a background rotation timer. The number of registry keys is not bounded; do not derive keys from uncontrolled high-cardinality input.

await registry.Remove($"tenant:{tenantId}", cancellationToken);

// Dispose every cached set and clear all history:
await registry.Clear(cancellationToken);

Removal disposes the cached instance. Do not continue using an instance after its key is removed. A later Get creates a fresh window with the newly supplied configuration. TryGet checks the cache without creating anything.

Dispose the registry itself at the end of its lifetime so all remaining rotation tasks are stopped.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.148 37 9/9/2026
4.0.147 37 9/9/2026
4.0.146 50 9/8/2026
4.0.145 51 9/8/2026
4.0.144 49 9/8/2026
4.0.142 68 9/7/2026
4.0.141 81 9/7/2026
4.0.140 75 9/7/2026
4.0.139 83 9/7/2026
4.0.138 87 9/5/2026
4.0.137 85 9/5/2026
4.0.136 88 9/4/2026
4.0.135 88 9/4/2026
4.0.134 85 9/4/2026
4.0.133 91 9/4/2026
4.0.132 91 9/4/2026
4.0.131 91 9/1/2026
4.0.130 94 8/31/2026
4.0.129 91 8/31/2026
4.0.126 92 8/30/2026
Loading failed

Update dependency Soenneker.Dictionaries.Singletons to 4.0.87 (#279)