Package com.mewna.catnip.shard.ratelimit
Class MemoryRatelimiter
java.lang.Object
com.mewna.catnip.shard.ratelimit.MemoryRatelimiter
- All Implemented Interfaces:
Ratelimiter
- Since:
- 8/16/18.
- Author:
- amy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncheckRatelimit
(String id, long periodMs, long limit) Checks if the id is ratelimited, based on the period and the limit-per-period.
-
Constructor Details
-
MemoryRatelimiter
public MemoryRatelimiter()
-
-
Method Details
-
checkRatelimit
public org.apache.commons.lang3.tuple.ImmutablePair<Boolean,Long> checkRatelimit(String id, long periodMs, long limit) Description copied from interface:Ratelimiter
Checks if the id is ratelimited, based on the period and the limit-per-period.- Specified by:
checkRatelimit
in interfaceRatelimiter
- Parameters:
id
- id to checkperiodMs
- period of ratelimit resetlimit
- max "uses" before ratelimit for a given period is hit- Returns:
- A (isRatelimited, amountRemaining) tuple
-