stefanprodan / WebApiThrottle

ASP.NET Web API rate limiter for IIS and Owin hosting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ConcurrentDictionaryRepository not being used appropriately.

sagarnarla opened this issue · comments

While ConcurrentDictionaryRepository offers a thread safe IThrottleRepository implementation the ThrottlingCore always acquires lock before using the IThrottleRepository. Thus obviating the need for thread safe implementation.
ThrottlingCore.cs line:198

lock (ProcessLocker)
{
var entry = Repository.FirstOrDefault(id);
// Code here
// stores: id (string) - timestamp (datetime) - total (long)
Repository.Save(id, throttleCounter, timeSpan);
}`

@stefanprodan: Doesn't this defeat the purpose of having a ConcurrentDictionaryRepository which is to remove the bottle neck where all requests are made to wait for the lock.