Rate limiting (ஒரு நேர கண்ணாடியில் எத்தனை requests/actions அனுமதிக்கப்படுகிறது என்பதைக் கட்டுப்படுத்துதல்) என்பது Redis இன் பொதுவான பயன்பாடு — Redis ന் வேகமான atomic counters மற்றும் TTLs இடம் கொடுக்கும் செய்கை. பல algorithms உள்ளன (fixed window, sliding window, token bucket), ஒவ்வொன்றும் trade-offs உள்ளது.
Fixed window (எளிமையான)
() {
key = ;
count = redis.(key);
(count === ) redis.(key, windowSec);
count <= limit;
}
