stefanprodan / WebApiThrottle

ASP.NET Web API rate limiter for IIS and Owin hosting
MIT License
1.28k stars 274 forks source link

ConcurrentDictionaryRepository not being used appropriately. #95

Open sagarnarla opened 7 years ago

sagarnarla commented 7 years ago

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.