-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atomic increment and expire #1
Comments
With Lua script such as: local current it will be bullet proof atomic, no race conditions at all. |
Looks to me like a great candidate for a pull request! |
Also, Lua is good because it moves time logic to Redis which means it will use central (Redis) time. |
@olegkv so... no pull request then? |
This commit adds an atomic 'set and expire key' operation to the rate limit counter store. |
Raised by olegkv in this thread:
Indeed the key creation and expiry is a little loose and in very rare cases can create keys that never expire or expire too early. The former case is a (very rare) problem for long-running caches, and I've had a crack at tightening it up a little on the branch atomic-incr-expireat (PRs welcome etc).
However the expectation for rate-limiting middleware is low latency, so this is preferred over formal correctness (within limits). I'll profile the branch and see how it goes. From the failure scenarios you describe, it sounds like your use-case requires consensus in a network of failing nodes, so maybe you're better served by something like an implementation of Raft?
The text was updated successfully, but these errors were encountered: