Skip to content

Allow heartbeating a request #7

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

Merged
merged 3 commits into from
Jun 20, 2025
Merged

Conversation

loganintech
Copy link

No description provided.

local count = 0
local bulk = redis.call('HGETALL', rate_limit_key)
local nextkey
for i, v in ipairs(bulk) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is O(N) on the number of requests for a key - is that OK?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not what I'd love to do but the N is going to be small and it's the same implementation as the way we calculate concurrency for take

for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
if tonumber(v) < now then
redis.call("HDEL", rate_limit_key, nextkey)
else
count = count + 1
end
end
end

@loganintech loganintech merged commit 42e6c04 into v11 Jun 20, 2025
2 checks passed
@loganintech loganintech deleted the logan/allow-heartbeating-request branch June 20, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants