I don't see how could I migrate that code, as it's deprecated (Bucket4j) or deleted (GridBucketState, JCache):
\nimport io.github.bucket4j.Bucket4j\nimport io.github.bucket4j.grid.GridBucketState\nimport io.github.bucket4j.grid.jcache.JCache\n\n private val cache: Cache<String, GridBucketState> = cacheManager.getCache(rateLimitProperties.cacheName)\n private val buckets = Bucket4j.extension(JCache::class.java).proxyManagerForCache(cache)\n.\n.\n.\nval bucket = buckets.getProxy(principal.name, configuration)\nval probe = bucket.tryConsumeAndReturnRemaining(1)\n
and in ehcache.xml config:
\n <cache alias=\"rate-limit-buckets\">\n <key-type>java.lang.String</key-type>\n <value-type>io.github.bucket4j.grid.GridBucketState</value-type>\n <expiry>\n <ttl>3600</ttl>\n </expiry>\n <heap>1000000</heap>\n <jsr107:mbeans enable-statistics=\"true\"/>\n </cache>\n
I changed my code to the following:
\nimport io.github.bucket4j.grid.jcache.JCacheProxyManager\n\n private val cache: Cache<String, ByteArray> = cacheManager.getCache(rateLimitProperties.cacheName)\n private val buckets = JCacheProxyManager(cache)\n.\n.\n.\nval bucket = buckets.builder().build(principal.name, configuration)\nval probe = bucket.tryConsumeAndReturnRemaining(1)\n
and removed key-type and value-type from ehcache.xml:
\n <cache alias=\"rate-limit-buckets\">\n <expiry>\n <ttl>3600</ttl>\n </expiry>\n <heap>1000000</heap>\n <jsr107:mbeans enable-statistics=\"true\"/>\n </cache>\n
It's working now, so I hope it's correct.
","upvoteCount":1,"url":"https://github.com/bucket4j/bucket4j/discussions/223#discussioncomment-2081427"}}}-
Hi. I'm trying to migrate from 6.4.1 to 7.1.0. In my project I'm using:
I don't see how could I migrate that code, as it's deprecated (Bucket4j) or deleted (GridBucketState, JCache):
and in ehcache.xml config:
|
Beta Was this translation helpful? Give feedback.
-
@pawelryznar hello, See this as an example of migration. And do not forget to read the documentation https://bucket4j.com/7.1.0/toc.html#bucket4j-jcache |
Beta Was this translation helpful? Give feedback.
-
I changed my code to the following:
and removed key-type and value-type from ehcache.xml:
It's working now, so I hope it's correct. |
Beta Was this translation helpful? Give feedback.
-
Hey @vladimir-bukhtoyarov , I've recently refactoring some code from java 11 to java 17, and I'm working with Ignite and bucket4J. This is how my configuration is implemented: `@Bean
The issue I'm getting is when I call the function getProxyConfiguration which is returning to me an expecption: Function: Optional buckConfig = proxyManager.getProxyConfiguration(bucketKey); Even when GridBucketState is no longer available on the lib 8.0.1, I'm still getting this error, do you have some thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
Hello @gustavofariaas I have two ideas according to
|
Beta Was this translation helpful? Give feedback.
I changed my code to the following:
and removed key-type and value-type from ehcache.xml:
It's working now, so I hope it's correct.