4 Replies Latest reply on Apr 14, 2011 1:16 PM by Dan Berindei

    Query Caching in Infinispan

    Meena Rajani Newbie

      Hi,

         I want to confirm that when we do query cache in infinispan, does it cache the object ids of the actual data or does it cache the actual objects?

      I read somewhere in hibernate that querycache cache only the ids. Can some one please confirm that, as far as I understand it, infinispan cache the actual data in object form.

       

       

      Regards

      Meena

        • 1. Query Caching in Infinispan
          Dan Berindei Expert

          Meena, Hibernate "owns" the query cache, so Infinispan can't store more information than Hibernate wants to store.

           

          On the other hand, Hibernate has another cache just for storing the actual data: the second level cache (which will also be using Infinispan). So if you would also store the object data in the query cache you would just waste memory by keeping the same data in two places.

          • 2. Query Caching in Infinispan
            Meena Rajani Newbie

            Hi  Dan,

             

            Hibernate "owns" the query cache, so Infinispan can't store more information than Hibernate wants to store.

            What if I want only Infinispan  as a 2nd level cache and Hibernate just for OR mapping

            In the documentation of Infinispan it says that there is query cache available in Infinispan. But I could not see any details if it is actually caching the objects or id's just as hibernate does?

             

            Thanks

            Meena

            • 3. Query Caching in Infinispan
              Chris Collison Newbie

              I've tested Infinispan as my 2LC provider and it seems to behave pretty much like hibernate as far as what it stores and how it stores it in each region. If a query is marked as cacheable it will keep the SQL/HQL statement and the keys in the query cache. If you have entities marked as cacheable it will cache those and the query cache can make use of those entities if it needs to "rehydrate" an entry.

              • 4. Query Caching in Infinispan
                Dan Berindei Expert

                Ok, now I'm not sure I answered the right question... I thought you wanted to use Hibernate as a 2nd level/query cache implementation for Hibernate. In that case Hibernate controls what gets stored in the cache and you don't access Infinispan directly.

                 

                It looks instead like you are using the Infinispan query module, and I don't know too much about that module. But I don't think it does any query caching, although Lucene may do some caching under the hood.