1 Reply Latest reply on Jun 6, 2016 9:52 AM by Galder Zamarreño

    How to Initialise a Tree Cache

    Paul Henry Newbie

      Hi All,

       

      I have a very basic question. I have looked in the documentation for 8.2 final and am trying to follow the instructions for initialising a Tree Cache eg Infinispan User Guide  as we want to migrate from Jboss Tree Cache to Infinispan Tree Cache.

       

      import org.infinispan.config.Configuration;
      import org.infinispan.tree.TreeCacheFactory;
      import org.infinispan.tree.TreeCache;
      ...
      Configuration config = new Configuration();
      config.setInvocationBatchingEnabled(true);
      Cache cache = new DefaultCacheManager(config).getCache();
      TreeCache treeCache = TreeCacheFactory.createTreeCache(cache);

       

      However the documentation appears to be out of date. The org.infinispan.config.Configuration class doesn't appear to exist in either the embedded jar or the tree-cache jar.

       

      If i simply try to create a tree cache with the following code

       

              TreeCacheFactory treeCacheFactory = new TreeCacheFactory();

              treeCache = treeCacheFactory.createTreeCache(new DefaultCacheManager().getCache());

       

      then i get the expected warning that invocation Batching has not been enabled.

       

      If i try and use the Configuration Object from org.infinispan.configuration.cache.Configuration then I cannot find how to set the Invocation Batching enabled. I assume that this is the correct config object to be using.

       

      Does anyone have a correction to the example in the docs? or can you help me find where to set the invocation Batching enabled on the Configuarion object.

       

      Thanks

      -Paul

        • 1. Re: How to Initialise a Tree Cache
          Galder Zamarreño Master

          Hmmmm, the tree module was designed in the early days of Infinispan but as time has passed we haven't kept it that up to date since most people would benefit from a flatter, map-like, structure. So, I'd recommend thinking about your data model and trying to flatten it out and use the Map-API. If it's too complex, maybe you could consider using Hibernate OGM.