Rate limiting (restricting how many requests/actions are allowed in a time window) is a common Redis use case — Redis's fast atomic counters and TTLs make it ideal. Several algorithms exist (fixed window, sliding window, token bucket), each with trade-offs.
Fixed window (simplest)
() {
key = ;
count = redis.(key);
(count === ) redis.(key, windowSec);
count <= limit;
}
