The one to use wherever the application runs as more than one process, which is the case that
warrants a limiter at all: per-process counters let every instance grant the full budget again.
One round trip per request, and no read. The window index is part of the key, so a new window is a
new key that starts at zero, and the counter's own expiry cleans up after it: there is nothing to
sweep and nothing to read-modify-write. INCR and the expiry travel in one pipeline, because an
INCR whose PEXPIRE never arrived is a counter that never resets, and one lost round trip would
lock a caller out of that key forever.
ioredis is imported lazily and is an optional peer, so this module carries no Redis weight until a
Redis limiter is actually configured.
Shared fixed-window limiter, over Redis.
The one to use wherever the application runs as more than one process, which is the case that warrants a limiter at all: per-process counters let every instance grant the full budget again.
One round trip per request, and no read. The window index is part of the key, so a new window is a new key that starts at zero, and the counter's own expiry cleans up after it: there is nothing to sweep and nothing to read-modify-write.
INCRand the expiry travel in one pipeline, because anINCRwhosePEXPIREnever arrived is a counter that never resets, and one lost round trip would lock a caller out of that key forever.ioredisis imported lazily and is an optional peer, so this module carries no Redis weight until a Redis limiter is actually configured.