PenaltyBox
A penalty box that can be used with EdgeRateLimiter or standalone for adding and checking if an entry is in the dataset.
Note: Can only be used when processing requests, not during build-time initialization.
Constructor
new PenaltyBox(name: string)Open a penalty box identified by the given name.
Parameters
- name: string
The name of the penalty box to open.
Methods
add
View sourceadd(entry: string, timeToLive: number): voidAdd an entry to the penalty box for the duration of the given timeToLive.
Parameters
- entry: string
The entry to add.
- timeToLive: number
How long in minutes (1–60) the entry should be added into the penalty box. Value is truncated to the nearest minute.
Returns
void
Throws
TypeErroriftimeToLiveis not a number between 1 and 60.
has
View sourcehas(entry: string): booleanCheck if an entry is in the penalty box.
Parameters
- entry: string
The entry to look up.
Returns
boolean
true if the entry is in the penalty box, otherwise false.