This repository was archived by the owner on Mar 9, 2026. It is now read-only.
add more discussion to INCR docu case studies#2722
Open
cbeck88 wants to merge 1 commit intoredis:masterfrom
Open
add more discussion to INCR docu case studies#2722cbeck88 wants to merge 1 commit intoredis:masterfrom
cbeck88 wants to merge 1 commit intoredis:masterfrom
Conversation
👷 Deploy request for redis-doc pending review.Visit the deploys page to approve it
|
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#4423 redis/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.)
cb8f339 to
162df3e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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#4423
redis/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.)