DistributedDebounceThrottle 1.0.0
dotnet add package DistributedDebounceThrottle --version 1.0.0
NuGet\Install-Package DistributedDebounceThrottle -Version 1.0.0
<PackageReference Include="DistributedDebounceThrottle" Version="1.0.0" />
paket add DistributedDebounceThrottle --version 1.0.0
#r "nuget: DistributedDebounceThrottle, 1.0.0"
// Install DistributedDebounceThrottle as a Cake Addin #addin nuget:?package=DistributedDebounceThrottle&version=1.0.0 // Install DistributedDebounceThrottle as a Cake Tool #tool nuget:?package=DistributedDebounceThrottle&version=1.0.0
DistributedDebounceThrottle
DistributedDebounceThrottle
is a .NET library designed to facilitate debounce and throttle mechanisms in distributed system environments, leveraging Redis for state management and distributed locking. This ensures that function executions are properly debounced or throttled across multiple instances, preventing excessive or unintended operations.
Features
- Debounce: Ensures a function is executed only once after a specified interval since the last call, useful for minimizing redundant operations over a period.
- Throttle: Limits the execution frequency of a function, ensuring it's not executed more than once within a specified timeframe.
- Distributed Locks: Implements the RedLock algorithm for distributed locking to coordinate debounce and throttle logic across distributed systems.
- Redis Integration: Utilizes Redis for managing timestamps and locks, offering a scalable solution for state synchronization.
Getting Started
Installation
Install DistributedDebounceThrottle
via NuGet:
dotnet add package DistributedDebounceThrottle
Usage
To integrate DistributedDebounceThrottle
in your application, ensure you have a Redis instance ready for connection. Here's how to get started:
1. Configure Services:
In your application's startup configuration, register DistributedDebounceThrottle:
public void ConfigureServices(IServiceCollection services)
{
// Using an existing IConnectionMultiplexer instance:
services.AddDistributedDebounceThrottle(settings);
// Or, initiating a new IConnectionMultiplexer with a connection string:
services.AddDistributedDebounceThrottle(redisConnectionString, settings);
}
2. Inject and Use IDebounceThrottle
:
Inject IDebounceThrottle
to access debounce and throttle dispatchers:
public class SampleService
{
private readonly IDispatcher _throttler;
public SampleService(IDebounceThrottle debounceThrottle)
{
_throttler = debounceThrottle.ThrottleDispatcher("uniqueDispatcherId", TimeSpan.FromSeconds(5));
}
public Task ExecuteThrottledOperation()
{
return _throttler.DispatchAsync(async () =>
{
// Operation logic here.
});
}
}
Configuration
Customize your debounce and throttle settings via DebounceThrottleSettings
:
RedisKeysPrefix
: A prefix for all Redis keys (default "debounce-throttle:").RedLockExpiryTime
: The expiry time for the distributed locks (default TimeSpan.FromSeconds(10)).
Contributing
Contributions are welcome! Feel free to fork the repository, submit pull requests, or report issues for bugs, features, or documentation improvements.
License
This project is licensed under the MIT License - see the LICENSE file in the repository for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- RedLock.net (>= 2.3.2)
- StackExchange.Redis (>= 2.7.33)
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 |
---|---|---|
1.0.0 | 150 | 4/10/2024 |