1 Reply Latest reply on Jun 14, 2016 2:57 AM by rvansa

    Hibernate Second Level Cache Statistics do not match Infinispan's statistics

    mjhaller

      I've been gettting statistics using the Hibernate Second Level Cache statistics API.  Say I have an entity called Foo (cacheName) I would get that like this:

       

        Statistics statistics = entityManager.getSession().getSessionFactory().getStatistics();
        statistics.setStatisticsEnabled(true);
        SecondLevelCacheStatistics l2cacheStats =  statistics.getSecondLevelCacheStatistics(cacheName);
      

       

      For a given instance of Foo, I see:

       

      ...
            "entries" : [ ... 134 individual records ... ]
             "hitCount": 0,
              "missCount": 0,
              "putCount": 134,
      ...
      


      But, viewing the Infinsipan MBean (org.Infinispan.Cache) over JMX for the same entity Foo, I see hits:



      statistics.png


      Before I dig into the internals of these two API can you think why there might be a difference?

       

       

       

        • 1. Re: Hibernate Second Level Cache Statistics do not match Infinispan's statistics
          rvansa

          Hibernate stats tell you how many times Hibernate fetched the entity from cache; Infinispan stats tell you how many times the 2LC implementation tried to read the data from the cache. I don't recall the details, but there may be additional reads during stores as well. If you want to reduce the number of reads, you can set 'hibernate.cache.use_minimal_puts' to false (I would recommend this for Infinispan 2LC generally).