Class Bucket4jRateLimiter

java.lang.Object
com.rale4j.sb.core.Bucket4jRateLimiter
All Implemented Interfaces:
RateLimitStrategy

@Component("bucket4j") public class Bucket4jRateLimiter extends Object implements RateLimitStrategy
Rate limiter implementation using Bucket4j.
  • Constructor Details Link icon

    • Bucket4jRateLimiter Link icon

      public Bucket4jRateLimiter()
  • Method Details Link icon

    • allowRequest Link icon

      public boolean allowRequest(String key, int limit, int duration)
      Description copied from interface: RateLimitStrategy
      Checks if a request is allowed based on the rate-limiting rules.
      Specified by:
      allowRequest in interface RateLimitStrategy
      Parameters:
      key - the unique key for the rate limit (e.g., user ID, IP)
      limit - the maximum number of requests allowed
      duration - the time window (in seconds) for the rate limit
      Returns:
      true if the request is allowed, false otherwise