Skip to content
\n

I don't see how could I migrate that code, as it's deprecated (Bucket4j) or deleted (GridBucketState, JCache):

\n
import 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
\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
","upvoteCount":1,"answerCount":4,"acceptedAnswer":{"@type":"Answer","text":"

I changed my code to the following:

\n
import 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
\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
\n

It's working now, so I hope it's correct.

","upvoteCount":1,"url":"https://github.com/bucket4j/bucket4j/discussions/223#discussioncomment-2081427"}}}

Migration from 6.4.1 to 7.1.0 - removed classes/functions #223

Answered by pawelryznar
pawelryznar asked this question in Q&A
Discussion options

You must be logged in to vote

I changed my code to the following:

import io.github.bucket4j.grid.jcache.JCacheProxyManager

    private val cache: Cache<String, ByteArray> = cacheManager.getCache(rateLimitProperties.cacheName)
    private val buckets = JCacheProxyManager(cache)
.
.
.
val bucket = buckets.builder().build(principal.name, configuration)
val probe = bucket.tryConsumeAndReturnRemaining(1)

and removed key-type and value-type from ehcache.xml:

    <cache alias="rate-limit-buckets">
        <expiry>
            <ttl>3600</ttl>
        </expiry>
        <heap>1000000</heap>
        <jsr107:mbeans enable-statistics="true"/>
    </cache>

It's working now, so I hope it's correct.

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@pawelryznar
Comment options

@vladimir-bukhtoyarov
Comment options

Comment options

You must be logged in to vote
1 reply
@vladimir-bukhtoyarov
Comment options

Answer selected by pawelryznar
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@gustavofariaas
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants