I am using Spring with Java 17, Bucket4j and Redisson for rate limiting. What I've noticed that after changing the property which defines the limit or the interval of the rate limit the bucket is not updated. It gets the old bucket from redis with the old limits and proceeds accordingly.
I have tried the same with Hazelcast and Bucket4j and it works as expected. The new configurations are loaded and it handles the limit changes. I want to achieve the same behavior with redis as well.
Here is the code fragment which fetches the bucket from redis:
private final RedissonBasedProxyManager<String> redissonProxyManager;
...
private BlockingBucket getBucket(String name, long limit, long interval) {
return redissonProxyManager.builder()
.build(name, () -> Bucket.builder()
.addLimit(Bandwidth.builder()
.capacity(limit)
.refillGreedy(limit, Duration.of(interval, ChronoUnit.SECONDS))
.build())
.build()
.getConfiguration())
.asBlocking();
}
I really want to avoid deleting the buckets manually every time I'm changing the rate limit.