Skip to content
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

feat(redis): add customIncrTtlLuaScript option #261

Merged
merged 6 commits into from
Apr 24, 2024

Conversation

roggervalf
Copy link
Contributor

@roggervalf roggervalf commented Apr 22, 2024

Allow providing a custom incrTtlLuaScript

@roggervalf roggervalf changed the title feat(redis): add delayMultiplierByGroupEnabled option feat(redis): add delayMultiplierByMaxPointsEnabled option Apr 22, 2024
@roggervalf
Copy link
Contributor Author

pls @animir when you get some time

@animir
Copy link
Owner

animir commented Apr 22, 2024

@roggervalf Hi. As I see you would like to double TTL of a key whenever consumes more than points? Do you need it to avoid extra requests to Redis? I am asking as I would like to understand your use case.

@roggervalf
Copy link
Contributor Author

roggervalf commented Apr 22, 2024

hey @animir, yes but more than double it, it would take how many point in batches are there to calculate the next delay, because when you already have the first batch of points, those are good to have the regular delay but for the second batch they will reach the same rate limit as the first batch came first

@roggervalf
Copy link
Contributor Author

so the delay for the next points depending on which batch they are included need to have extra delays

@roggervalf
Copy link
Contributor Author

pls @animir let me know if you have questions about it

@animir
Copy link
Owner

animir commented Apr 23, 2024

@roggervalf I do have doubts about bringing this customization to the project.
It would be hard to explain how it works.
And I believe nobody, except you, would use it.

Could you implement it a different way? I suggest to consider settings custom Lua script from outside?
If there would be an ability to set custom Lua script when create RateLimiterRedis you could use you custom code there.
Let me know what you think.

@roggervalf
Copy link
Contributor Author

sure I can do it

@roggervalf roggervalf changed the title feat(redis): add delayMultiplierByMaxPointsEnabled option feat(redis): add customIncrTtlLuaScript option Apr 23, 2024
lib/RateLimiterRedis.js Show resolved Hide resolved
lib/RateLimiterRedis.js Show resolved Hide resolved
@roggervalf
Copy link
Contributor Author

it should be ready now, pls when you get some time @animir

@animir animir merged commit bdf5965 into animir:master Apr 24, 2024
7 checks passed
@animir
Copy link
Owner

animir commented Apr 24, 2024

@roggervalf Published in 5.0.1.

@roggervalf roggervalf deleted the feat-delayMultiplierByGroupEnabled branch April 24, 2024 18:40
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.

2 participants