-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getAvailableTokensPerEachBandwidth() #279
Comments
Hello, First of all, it worth to mention that bucket4j-spring-boot-starter is separated project and is maintained by another guys. The test behaves as expected: Remaining tokens = 3
Tokens per bandwidth = [3, 9]
Remaining tokens = 2
Tokens per bandwidth = [2, 8]
Remaining tokens = 1
Tokens per bandwidth = [1, 7]
Remaining tokens = 0
Tokens per bandwidth = [0, 6] Looks that you are using https://github.com/MarcGiffing/bucket4j-spring-boot-starter/blob/master/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/RedisProxyManager.java from bucket4j-spring-boot-starter and there are problems in implementation. Currently I have no time to debug and find out which concrete problem in this class, but it worth to mention that since bucket4j release 7.6.0 there is no reasons to continue using of RedisProxyManager from bucket4j-spring-boot-starter because support for Letucce, Jedis and SpringDataRedis was directly added to Bucket4j. |
@ttulka @MarcGiffing Hello guys, Looks that https://github.com/MarcGiffing/bucket4j-spring-boot-starter/blob/master/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/RedisProxyManager.java can be removed after upgrading to Bucket4j 7.6.0 |
@vladimir-bukhtoyarov I managed to reproduce the issue using JCache, here is the PR with the configuration I used. |
@vladimir-bukhtoyarov That change fixes the issue for this particular case. |
@iliyanvelchevio hello, I am going to close both merge requests without merge because of I will provide more optimal fix, as well as more optimal test. |
@vladimir-bukhtoyarov Great, I just wanted to give you more information on how to reproduce the issue and a potential fix. |
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 4c3ea89 |
Fix has been included to release 8.0.1 |
Hello,
I am using bucket4j with Redis:
When I configure a bucket with the following bandwidths:
and consume 1 token multiple times using the verbose API:
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):
Second consumption:
Third consumption:
Fourth consumption:
The text was updated successfully, but these errors were encountered: