stefanprodan/AspNetCoreRateLimit

Per user rate limit with seeding of the current usages

Closed this issue · 1 comments

Hi,

I am trying to implement a logic to rate limit the calls per user, effective by a pricing tier that a user is on.

For example:

  • Anonymous user: 1,000 calls per month
  • Registered free user: 2,000 calls per month
  • Standard user: 10,000 calls per month
  • Premium user: 100,000 calls per month

I followed #396 and it could seed the limits per user.

However, I could not find a way to set/seed the current usage of the user. For example, when the application restarts, it will lose the usage statstics, right?

Do we have a mechanism to support it? Or at least we can write some logic to add to the existing middleware?

Thanks

With a combination of #369 and #152 , I managed to use IRateLimitingService.SetAsync to set the counter per period.