CounterStore for ThrottlingTroll. Stores counters in ASP.Net Core's IDistributedCache.
$ dotnet add package ThrottlingTroll.CounterStores.DistributedCacheICounterStore implementation that uses ASP.NET Core's IDistributedCache.
Fast, but not entirely consistent (because IDistributedCache does not provide atomic operations). In other words, your computing instances might go slightly on their own. For true consistency consider using ThrottlingTroll.CounterStores.Redis instead.
Install package from NuGet:
dotnet add package ThrottlingTroll.CounterStores.DistributedCache
Configure an IDistributedCache option of your choice as described here.
EITHER put DistributedCacheCounterStore instance into your DI container:
builder.Services.AddSingleton<ICounterStore>(provider =>
new DistributedCacheCounterStore(provider.GetRequiredService<IDistributedCache>())
);
OR provide an instance of it via .UseThrottlingTroll() method:
app.UseThrottlingTroll(options => {
options.CounterStore = new DistributedCacheCounterStore(app.Services.GetRequiredService<IDistributedCache>());
});