Bucket4j and infinispan #366
-
Hi, `3.4.4. Example of Bucket instantiation ... Bucket bucket = proxyManager.builder().build(configuration);` how to instantiate the map variable? My intention is to control the rate limit from IP to certain request paths (like public domains) inside a servlet filter. Cheers, and thanks by advanced. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @git-volver
According to Infinispan documentation it is possible https://infinispan.org/docs/stable/titles/encoding/encoding.html#registering-sci-embedded-caches_marshalling
If you have an instance of private static ReadWriteMap<String, byte[]> toMap(Cache<String, byte[]> cache) {
FunctionalMapImpl<String, byte[]> functionalMap = FunctionalMapImpl.create(cache.getAdvancedCache());
return ReadWriteMapImpl.create(functionalMap);
} See this test if something unclear according to map instantiation https://github.com/bucket4j/bucket4j/blob/master/bucket4j-infinispan-all/bucket4j-infinispan/src/test/java/io/github/bucket4j/grid/infinispan/InfinispanTest.java |
Beta Was this translation helpful? Give feedback.
Hello @git-volver
According to Infinispan documentation it is possible https://infinispan.org/docs/stable/titles/encoding/encoding.html#registering-sci-embedded-caches_marshalling
If you have an instance of
org.infinispan.Cache
then initialization of finctional map is trivial: