Reputation: 493
I'm using Infinispan ( 9.4.5.Final ) to store data locally in caches.
To do so, i'm using this piece of code ( from https://www.baeldung.com/infinispan)
private Configuration passivatingConfiguration() {
return new ConfigurationBuilder()
.memory().evictionType(EvictionType.COUNT).size(1)
.persistence()
.passivation(true) // activating passivation
.addSingleFileStore() // in a single file
.purgeOnStartup(true) // clean the file on startup
.location(System.getProperty("java.io.tmpdir"))
.build();}
Each time I put something in the cache, i'm printing its size :
cache.size()
The cache size should be constant to 1 but it can't stop increasing...
I'm trying with another piece of code :
private Configuration evictingConfiguration() {
return new ConfigurationBuilder()
.memory().evictionType(EvictionType.COUNT).size(1)
.build();}
And... it's working... the size of the cache is always 1.
I want the memory to be fixed. Does anymone experiencing the same issue ?
Upvotes: 0
Views: 256
Reputation: 901
You have configured a cache store. If you notice the size javadoc mentions it includes cache loaders in its invocation https://docs.jboss.org/infinispan/10.0/apidocs/org/infinispan/Cache.html#size--
If you want to only retrieve the size of entries in memory try the following instead:
cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).size();
Upvotes: 1