Skip to content

fix 2 bugs for redis: ttl -1 and X-RateLimit-Reset#39

Open
codeHui wants to merge 1 commit into
ysocorp:developfrom
codeHui:bugFix/codeHui/redisTtlResetTime
Open

fix 2 bugs for redis: ttl -1 and X-RateLimit-Reset#39
codeHui wants to merge 1 commit into
ysocorp:developfrom
codeHui:bugFix/codeHui/redisTtlResetTime

Conversation

@codeHui

@codeHui codeHui commented Jan 6, 2022

Copy link
Copy Markdown

1,"dateEnd===-1" may happen just after ttl expires then "await this.client.incrBy(key, weight)" will set ttl to -1; we count this low probability requests as the previous period and check "dateEnd===-1" for the next request

2,add "dateEnd = Date.now() + dateEnd * 1000;" the unit of Date.now() is millisecond, this affect "X-RateLimit-Reset"

I am happy if I could contribute the code, and any questions is welcome

1,"dateEnd===-1" may happen just after ttl expires then "await this.client.incrBy(key, weight)" will set ttl to -1; we count this low probability requests as the previous period and check "dateEnd===-1" for the next request

2,add "dateEnd = Date.now() + dateEnd * 1000;" the unit of Date.now() is millisecond
@zjy01

zjy01 commented Feb 13, 2022

Copy link
Copy Markdown

I was in the same situation.

@zjy01 zjy01 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@edelache edelache left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I can confirm, this fixes the two bugs.

@openam

openam commented Sep 26, 2025

Copy link
Copy Markdown

Looks like #44 fixed the first issue. I was hoping there's a chance of getting the X-RateLimit-Reset fix in, but it seems like there's no movement in this project.

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.

4 participants