1 Reply Latest reply on Mar 19, 2012 5:27 AM by Galder Zamarreño

    Eviction maxEntries attribute

    bevans88 Newbie



      I'm currently investigating the evitction policies available in Infinispan and have noticed some unexpected(?) functionality in regards to setting maxEntries.

      If i set maxEntries to 10, and then add 10 entries to the cache only 7 of them will remain in the cache, with 3 apparently being evicted. I would expect for all 10 to remain in the cache... The code for this basic test is below (I have tried with a configuration xml as well and have had the same results)


         public static void main(String[] args) throws Exception {


              EmbeddedCacheManager manager = new DefaultCacheManager();


              manager.defineConfiguration("eviction-cache", new ConfigurationBuilder()




              Cache<Object, Object> evictionC = manager.getCache("eviction-cache");


              int counter = 0;

              while (counter < 10) {

                  evictionC.put("key" + counter, "" + counter);








      This results in the following being output into the console:


      7 (size)

      [9, 8, 7, 4, 0, 5, 3] (values)


      Any help with this would be appreciated.