Closed cmizzi closed 4 years ago
Could you provide more examples where this in-memory rate limiter implementation makes sense? I'm not convinced that it could be useful anywhere else but in unit tests for example.
Could you provide more examples where this in-memory rate limiter implementation makes sense? I'm not convinced that it could be useful anywhere else but in unit tests for example.
cron
, a worker
);I developed the support this way to best match the implemented version of Redis.
I think that's not a valid reason, why does it need to have same internals as the one using Redis as a backend? In-memory rate limiter is supposed to be lightweight, optimized for performance, and I feel like modeling it after Redis, Memcached or any other implementation is not necessary and can be counter-productive.
The implementation is light, it only calls for a few methods that make it easier to understand what's going on, the reading is fluid in my opinion. It's very easily readable and understandable. But if it bothers you, I can implement a "lighter" version.
@cmizzi Any updates on the alternative version?
@nikolaposa Sorry, I haven't had time to look yet. I'm watching this ASAP.
Closing in favor of: https://github.com/nikolaposa/rate-limit/pull/32
This simple addition makes it possible to support an array in order to use the rate limit (no need for Redis). Of course, it removes the cluster side but there are cases where it is interesting not to use Redis but a simple array to use the rate limit as an example simple scripts with a token that is not present in the database but hardcoded.
It might also be interesting to create an abstract class in order to make all the different possible supports.