Package com.rale4j.sb.core
Class RedisRateLimiter
java.lang.Object
com.rale4j.sb.core.RedisRateLimiter
- All Implemented Interfaces:
RateLimitStrategy
Rate limiter implementation using Redis.
-
Constructor Summary
ConstructorsConstructorDescriptionRedisRateLimiter(org.springframework.data.redis.core.RedisTemplate<String, String> redisTemplate) Constructor for RedisRateLimiter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowRequest(String key, int limit, int duration) Allows or denies a request based on the rate limit.
-
Constructor Details
-
Method Details
-
allowRequest
Allows or denies a request based on the rate limit.- Specified by:
allowRequestin interfaceRateLimitStrategy- Parameters:
key- the key to identify the rate limit bucketlimit- the maximum number of requests allowedduration- the duration in seconds for the rate limit- Returns:
- true if the request is allowed, false otherwise
-