I would like to use Infinispan as cache for image binary data (Java type byte). I assume that Infinispan default strategy is LIFO or similar strategy that prefers to keep most recently used/added cache entity.
In my loadtest scenario I make four calls in the round to retrieve the same entity. It is assumed that first call never hits the cache (because each round a unique entity is requested), but following three always hit the cache. So the expected profile should look like this:
It works perfectly (exactly as expected above) when I configure Infinispan with COUNT eviction type with some number of entities:
Cache hit ratio based on numbers I capture in loadtest: (2952-738)/2952 = 0.75 and that matches the stats I observe via JMX.
When I change the number of entities to keep in the memory (<binary eviction="COUNT" size="100" />), hit ratio does not change (as expected).
After that I have restarted the application with only this small change in cache configuration:
I would expect that Infinispan performance has the same profile, however it turns out that once the given amount of memory is fully allocated, newly added entities don't evict old entities but get immediately evicted. It means that roughly after 100 entities are added, all four requests to cache result cache miss (the ratio is now 0.58 instead of 0.75):
If I increase the memory, indeed hit ratio comes closer to 0.75 however I would like hit ratio to be the same irrespective the memory size (provided that memory can fit at least few entities).
Once I configure the passivation to file, memory-based eviction policy starts to work as expected:
but I would like to force the profile I need without passivation enabled.
Additional information is provided on the forum.
Bottomline: If underlying component supports different eviction "modes", please expose this setting via XML so that the user of the library can control the mode.