vutran1710 / PyrateLimiter

⚔️Python Rate-Limiter using Leaky-Bucket Algorithm Family
https://pyratelimiter.readthedocs.io
MIT License
334 stars 36 forks source link

Updated LUA script to avoid CROSSSLOT errors when using a Redis cluster #151

Closed vaharoni closed 6 months ago

vaharoni commented 6 months ago

When using a Redis Cluster, LUA scripts may strictly enforce the meaning of KEYS and ARGS. Specifically, strings in KEYS need to reflect keys in the Redis keyspace, and their hash portion is used to determine the slot where the key resides. The original LUA script conflated KEYS and ARGS. This caused CROSSSLOT errors. This PR separates KEYS and ARGS to avoid these issues.

This fixes issue https://github.com/vutran1710/PyrateLimiter/issues/126.

vutran1710 commented 6 months ago

Hi @vaharoni Tks for this wonderful fix!

Can you help fix the remaining lint fail?

vaharoni commented 6 months ago

Thanks @vutran1710, fixed the lint issues.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (7a04d79) 96.91% compared to head (5846c52) 96.91%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #151 +/- ## ======================================= Coverage 96.91% 96.91% ======================================= Files 13 13 Lines 714 714 Branches 85 84 -1 ======================================= Hits 692 692 Misses 15 15 Partials 7 7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.