Class RateLimitService

java.lang.Object
org.tavall.couriers.api.web.service.utils.RateLimitService

@Service public class RateLimitService extends Object
  • Constructor Details

    • RateLimitService

      public RateLimitService()
  • Method Details

    • isAllowed

      public boolean isAllowed(String clientIp, int cooldownMs)
      Checks if a client is allowed to proceed based on a cooldown.
      Parameters:
      clientIp - The IP address of the caller.
      cooldownMs - The required wait time in milliseconds.
      Returns:
      true if they can proceed, false if they're spamming.
    • clearOldRecords

      public void clearOldRecords()