public class RedisRateLimiter extends Object implements RateLimiter
RateLimiter.Response
Modifier and Type | Field and Description |
---|---|
static String |
BURST_CAPACITY_KEY |
static String |
REPLENISH_RATE_KEY |
Constructor and Description |
---|
RedisRateLimiter(org.springframework.data.redis.core.ReactiveRedisTemplate<String,String> redisTemplate,
org.springframework.data.redis.core.script.RedisScript<List<Long>> script) |
Modifier and Type | Method and Description |
---|---|
static org.springframework.tuple.Tuple |
args(int replenishRate,
int burstCapacity) |
reactor.core.publisher.Mono<RateLimiter.Response> |
isAllowed(String id,
org.springframework.tuple.Tuple args)
This uses a basic token bucket algorithm and relies on the fact that Redis scripts
execute atomically.
|
public static final String REPLENISH_RATE_KEY
public static final String BURST_CAPACITY_KEY
public static org.springframework.tuple.Tuple args(int replenishRate, int burstCapacity)
public reactor.core.publisher.Mono<RateLimiter.Response> isAllowed(String id, org.springframework.tuple.Tuple args)
isAllowed
in interface RateLimiter
id
- args
- Copyright © 2017 Pivotal Software, Inc.. All rights reserved.