You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The discussion about implementing a rate limiter pattern contained
in the docu about INCR command may lead one to think that the rate
limiter pattern is made somewhat more complicated due to INCR not
having NX features similar to SET. This is because a very simple
but flawed example is demonstrated, and the working solutions all
either use timestamps within the buckets (which adds complexity,
and raises questions about clock synchronization across servers),
or use lua scripting, or use redis lists. Meanwhile an NX feature
on INCR would seem to solve the problem pointed out in the flawed example.
This idea re-appears in github issues where users request additional
features to be added to INCR, and point to rate limiter as a motivation:
redis/redis#4423redis/redis#7631
In all the comments, more experienced users explain how you can already
basically do this using a MULTI pipeline, and you can use NX in that
pipeline as well if you want, which would accomplish what these feature
requests seem to be asking for. However, this idea doesn't actually
appear in the case studies in the documentation.
Expanding the case studies to include this idea, and working through
explicitly how it avoids race conditions and pitfalls described in the
other approaches, may be helpful to users. (It was helpful to me.)
0 commit comments