问题
I use infinispan cache version 5.1.6.FINA. I have configured named cache:
<namedCache name="cacheName">
<locking lockAcquisitionTimeout="5000" />
<eviction maxEntries="10" strategy="NONE" />
<expiration lifespan="-1" maxIdle="-1" />
</namedCache>
I use it to store some data in memory only. I use this configuration during creating cache where key is Long
and value is String
and hold there only 4 elements always only 4. For this purpose I have hardcoded 4 keys: 1L, 2L, 3L, 4L and sometimes just change values of those elements.
If cache holds 2 elements with key 1L and 2L and some values and I try to add other two with his values, they replays each other. So as a result cache holds just 3 element with keys 1L, 2L, 3L or 1L, 2L, 4L. I've tried to change eviction strategy but is doesn't help. Additionally I can say that it is local environment, non clustering.
Could someone to explain me this behavior?
回答1:
If you have maxEntries=10
, I'd expect you would have ±8 entries in the cache, not just 3. But generally, the answer is here:
- Cache’s number of entries never reaches configured maxEntries, why is that?
- Advanced Eviction Internals (also described here)
来源:https://stackoverflow.com/questions/24185830/infinispan-data-eviction