Need to manually delete the bucket on redis for the newly configured bucket to take effect? #329
-
hello, @vladimir-bukhtoyarov I found that I set a bucket with a capacity of 1 and a replenishment speed of 5 seconds plus 1 token on redis. Let's call it bucket 1 for now, but I want to change it to a bucket with a capacity of 5 and replenish 5 tokens in 5 seconds. For the time being Call it Bucket 2. I need to delete bucket 1 in redis by myself, and bucket 2 can be implemented. //bucket1
String key = "127.0.0.1";
//Capacity is 1, replenishment speed is 5 seconds each
Bandwidth bandwidth = Bandwidth.classic(2, Refill.intervally(1, Duration.ofSeconds(5)));
BucketConfiguration build = BucketConfiguration.builder().addLimit(bandwidth).build();
RedisURI redisURI = RedisURI.create("127.0.0.1", 6379);
RedisClient redisClient = RedisClient.create(redisURI);
ProxyManager proxyManager =
LettuceBasedProxyManager.builderFor(redisClient)
.withExpirationStrategy(ExpirationAfterWriteStrategy.none())
.build();
Bucket bucket = proxyManager.builder().build(key, build);
bucket.tryConsume(1); // bucket2
String key = "127.0.0.1";
//The capacity is 5 and the replenishment speed is 5 seconds each
Bandwidth bandwidth = Bandwidth.classic(5, Refill.intervally(5, Duration.ofSeconds(5)));
BucketConfiguration build = BucketConfiguration.builder().addLimit(bandwidth).build();
RedisURI redisURI = RedisURI.create("127.0.0.1", 6379);
RedisClient redisClient = RedisClient.create(redisURI);
ProxyManager proxyManager =
LettuceBasedProxyManager.builderFor(redisClient)
.withExpirationStrategy(ExpirationAfterWriteStrategy.none())
.build();
Bucket bucket = proxyManager.builder().build(key, build);
bucket.tryConsume(1); bucket4j version 7.6.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @licy12306 There is special functionality for configuration replacement https://bucket4j.com/8.1.1/toc.html#configuration-replacement |
Beta Was this translation helpful? Give feedback.
Hello @licy12306
There is special functionality for configuration replacement https://bucket4j.com/8.1.1/toc.html#configuration-replacement