Count one hit and say whether it may proceed.
What the budget belongs to.
How many hits the window allows.
How long the window lasts.
The verdict.
StaticcreateThe limiter's configuration.
A limiter.
StaticdisconnectClose every connection this driver opened, and forget them.
For a graceful shutdown, and for a test that wants none left behind. An application that never calls it loses nothing: the connections go with the process.
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.