Skip to content
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
cbeck88:add-discussion-to-incr-docu
Open

add more discussion to INCR docu case studies#2722
cbeck88 wants to merge 1 commit intoredis:masterfrom
cbeck88:add-discussion-to-incr-docu

Conversation

@cbeck88
Copy link
Copy Markdown

@cbeck88 cbeck88 commented Feb 5, 2025

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.)

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 5, 2025

👷 Deploy request for redis-doc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 162df3e

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 5, 2025

CLA assistant check
All committers have signed the CLA.

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.)
@cbeck88 cbeck88 force-pushed the add-discussion-to-incr-docu branch from cb8f339 to 162df3e Compare February 5, 2025 10:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants