getAvailableTokensPerEachBandwidth()
See original GitHub issueHello, I am using bucket4j with Redis:
<dependencies>
<dependency>
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
<artifactId>bucket4j-spring-boot-starter</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.17.5</version>
</dependency>
<dependencies>
When I configure a bucket with the following bandwidths:
Bandwidth.classic(4, Refill.intervally(4, Duration.ofMinutes(20)))
Bandwidth.classic(10, Refill.intervally(10, Duration.ofMinutes(60)))
and consume 1 token multiple times using the verbose API:
VerboseResult<ConsumptionProbe> verboseResult = bucket.asVerbose().tryConsumeAndReturnRemaining(1);
I get incorrect results reported by the getAvailableTokensPerEachBandwidth() method as shown bellow:
First consumption (the bucket is created and stored in Redis for the first time):
verboseResult.getValue().getRemainingTokens() -> 3
verboseResult.getDiagnostics().getAvailableTokensPerEachBandwidth() -> [3, 9]
Second consumption:
verboseResult.getValue().getRemainingTokens() -> 2
verboseResult.getDiagnostics().getAvailableTokensPerEachBandwidth() -> [3, 9]
Third consumption:
verboseResult.getValue().getRemainingTokens() -> 1
verboseResult.getDiagnostics().getAvailableTokensPerEachBandwidth() -> [2, 8]
Fourth consumption:
verboseResult.getValue().getRemainingTokens() -> 0
verboseResult.getDiagnostics().getAvailableTokensPerEachBandwidth() -> [1, 7]
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Results From Across the Web
VerboseResult.Diagnostics (bucket4j-core 7.5.0 API)
long[] getAvailableTokensPerEachBandwidth(). Returns currently available tokens per each bandwidth. Element's order inside resulted array depends from order ...
Read more >VerboseResult.Diagnostics (bucket4j-core 8.0.1 API)
Returns time in nanoseconds that need to wait until bucket will be fully refilled to its maximum. long, getAvailableTokens().
Read more >Last issues related to infinispan - PullAnswer
Invalid Hazelcast documentation for 7.x & 8.x docs · Kotlin-based implementation for multiplatform scanarios · getAvailableTokensPerEachBandwidth().
Read more >About serial port programming - Platformio/Platform-Ststm32
Issue Title, Created Date, Comment Count, Updated Date. getAvailableTokensPerEachBandwidth(), 8, 2022-07-25, 2022-10-05.
Read more >bucket4j - bytemeta
getAvailableTokensPerEachBandwidth(). manang. manang CLOSED · Updated 3 months ago · wait until token is available. Previous Next.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The problem was in inacurate implementation of VerboseCommand, it was not working correctly when implementation of MutableBucketEntry does not cache the result of get/set in memory, it is at least all JCache and similar integrations like Hazelcast/Ignite/Coherence.
Has been fixed by commit https://github.com/bucket4j/bucket4j/commit/4c3ea89e931784d7e8ea078bb9dc5381f03cff6d Will be released at weekend with version 8.0.1, maybe faster, it depends from progress on https://github.com/bucket4j/bucket4j/issues/241
Fix has been included to release 8.0.1 Also, groupId has been changed from
com.github.vladimir-bukhtoyarov
tocom.bucket4j
.