1 Reply Latest reply on Mar 4, 2013 8:28 AM by Galder Zamarreño

    Question related to eviction

    Carlos Gulden Newbie

      Hi I'm new in world infinispan, I have a couple of questions: When I put 50k nodes , the eviction start to evict some nodes even when maxEntries is 50k. I can check this for property of cache (size). I missed something,  It's correct , eviction works this way?. I dont use passivation to store nodes. Any help how to do this . This is my file conf xml :

       

      Hi again, I was seeing some examples with eviction, I made this simple test:

       

       

      import java.io.BufferedReader;
      import java.io.InputStreamReader;
      import org.infinispan.Cache;
      import org.infinispan.manager.DefaultCacheManager;

      public class Demo {

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

           DefaultCacheManager m = new DefaultCacheManager("conf.xml");  
           //Cache<String, Person> cache = m.getCache();
           Cache cache = m.getCache("evictionCache");
           m.start();
           cache.start();
          
           Sleep("Put 100 nodos...");
           Agregar(cache,1,100);
               
           Sleep("Cantidad de nodos en cache");
        System.out.println(cache.size());

           for (int j=1;j<=100;j++)
         {
          Get(cache,j);
         } 
          
        Sleep("Drop Cache ...");
        cache.clear();
        cache.stop();
        m.stop();
          }

          public static void Agregar(Cache c,Integer i,Integer f)
          {
           for (int j=i;j<=f;j++)
         {
          c.put("key"+j , "dato"+j);
         }   
          }
         
      public static void Sleep(String b){
        try{
         BufferedReader leerEntrada = new BufferedReader(new InputStreamReader(System.in));
         System.out.println(b);
         System.out.println("Pulse una tecla para continuar ...");
         String salida = leerEntrada.readLine();
        } catch( Exception e) {
         e.printStackTrace();
        }
      }

          public static void Get(Cache c,Integer n)
          {
           try{
           String d = (String)c.get("key"+n);
           System.out.println( d );
           }
           catch(Exception e)
           {
            e.printStackTrace();
           }
          }

      }

       

      I set the following properties for eviction:

      <eviction maxEntries="100"  strategy="LRU" />

      And to prevent that nodes never expire of the cache

      <expiration maxIdle="-1" wakeUpInterval="-1" lifespan="-1" />

      but when I put data into the 100 nodes, the eviction begins to eliminates  some random amount of nodes.

      Any help to prevent this from happening, thks.