10 Replies Latest reply on Feb 12, 2010 7:22 AM by Galder Zamarreño

    Hiberante 2L-querycache with Infinispan not so effective as with EhCache

    Guenther Demetz Newbie

      Doing some tests we discovered that with Infinispan cached querys are not recognized as UpToDate

      when the query call (= the chache put) happens within 100ms after the last UpdateTimestamps invalidation.

      This is because Infinispan defines a rather low timestamp granular precision, indeed ehcache's precision goes into milliseconds.

       

       

      InfinispanRegionFactory.java:


      public long nextTimestamp() {
            return System.currentTimeMillis() / 100;
         }


      EHCache-TimeStamper:

       

      public static long next() {
                synchronized(Timestamper.class) {
                     long newTime = System.currentTimeMillis() << BIN_DIGITS;
                     if (time<newTime) {
                          time = newTime;
                          counter = 0;
                     }
                     else if (counter < ONE_MS - 1 ) {
                          counter++;
                     }
                    
                     return time + counter;
                }
           }

      regards

      G.D.