Redis optimization: avoid querying Redis when threshold is violated #384
Replies: 3 comments 10 replies
-
Hello @oleg-smith Refill is not a single source of increasing tokens in the bucket. There are API that can to increasing tokens in the bucket: So, proposed optimization can not be applied by default because library does not know the scope of API that user intents to call. Anyway, this kind of optimization can be configured expilitly. There are big package of library that is not documented yet https://github.com/bucket4j/bucket4j/tree/8.4/bucket4j-core/src/main/java/io/github/bucket4j/distributed/proxy/optimization this package is addressed to implement varios optimization strategeis, feel free to read javadocs for classes in this packet, it can be interesting. I have just added optimization for your use case in this commit d1e4d75 The class HazelcastSkipSyncOnZeroExample shows how to use this optimization: |
Beta Was this translation helpful? Give feedback.
-
Hi @vladimir-bukhtoyarov, I tried it this way:
Then, accessing the same bucket from multiple threads this way:
in debug, I'm seeing Also, in the debug, the optimization object is always a new object the way I use it above - I assume that is the issue.
|
Beta Was this translation helpful? Give feedback.
-
released with version 8.4.0 |
Beta Was this translation helpful? Give feedback.
-
Hi, I would like to verify Redis integration behavior for this scenario:
Would the library query Redis for the rest of the minute, knowing the threshold had been already violated?
If it will query Redis by default, is there a way to configure it not to?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions