4 Replies Latest reply on Jan 31, 2012 11:15 AM by sannegrinovero

    Problem with Infinispan 5.1.0.FINAL and put with lifespan parameter

    damiano.pezzotti

      Hi,

      I'm trying to migrate my application to Infinispan 5.1.0.FINAL but I have some problem.

       

      My code uses put method passing lifespan parameter. In the new Infinispan version it seems that if I put an entry to the cache with a lifespan (e.g. 10 seconds) and then, after 5 seconds, I put the same entry with lifespan = 10 seconds, the lifespan is not overrided and the cache entry expires after 10 seconds from the first operation.

       

      Here an example of code that reproduces the problem:

       

              final Cache cache = .... // Obtain cache instance

             

              // Put entry in cache

              cache.put( "key_001", "v_001", 10, TimeUnit.SECONDS );

       

              int x = 0;

              while ( true ) {

                  // print cache entry every 500ms

                  System.out.println( ( x++ * 500 ) + "--->" + cache.get( "key_001" ) );

       

                  // every 5 seconds put the same entry with lifespan = 10 seconds

                  if ( x % 10 == 0 ) {

                      System.out.println("PING");

                      cache.put( "key_001", "v_001", 10, TimeUnit.SECONDS );

                  }

                  Thread.sleep( 500 );

              }

       

      The results is:

      0--->v_001

      500--->v_001

      1000--->v_001

      1500--->v_001

      2000--->v_001

      2500--->v_001

      3000--->v_001

      3500--->v_001

      4000--->v_001

      4500--->v_001

      PING

      5000--->v_001

      5500--->v_001

      6000--->v_001

      6500--->v_001

      7000--->v_001

      7500--->v_001

      8000--->v_001

      8500--->v_001

      9000--->v_001

      9500--->v_001

      PING

      10000--->null

      10500--->null

      11000--->null

      11500--->null

      12000--->null

      12500--->null

      13000--->null

      13500--->null

      14000--->null

      14500--->null

      PING

      15000--->v_001

      15500--->v_001

      16000--->v_001

      16500--->v_001

      17000--->v_001

      17500--->v_001

       

      With Infinispan 5.0.1 the result is

      0--->v_001

      500--->v_001

      1000--->v_001

      1500--->v_001

      2000--->v_001

      2500--->v_001

      3000--->v_001

      3500--->v_001

      4000--->v_001

      4500--->v_001

      PING

      5000--->v_001

      5500--->v_001

      6000--->v_001

      6500--->v_001

      7000--->v_001

      7500--->v_001

      8000--->v_001

      8500--->v_001

      9000--->v_001

      9500--->v_001

      PING

      10000--->v_001

      10500--->v_001

      11000--->v_001

      11500--->v_001

      12000--->v_001

      12500--->v_001

      13000--->v_001

      13500--->v_001

      14000--->v_001

      14500--->v_001

      PING

      15000--->v_001

      15500--->v_001

      16000--->v_001

      16500--->v_001

      17000--->v_001

      17500--->v_001

       

      Is it a bug?

       

      Thanks