2 Replies Latest reply on Feb 15, 2018 11:41 AM by Alex Furmanski

    Why is near caching a configuration property?

    Alex Furmanski Newbie

      My application uses Hotrod to interact with three caches in a remote cluster.  Two are large but one only contains a handful of frequently used items so I'd like to enable near caching on the small cache but not on the two large caches.  Unfortunately near caching is a property on the configuration supplied to the RemoteCacheManager, which implies that I need to have two RemoteCacheManagers with identical configs except for the near caching.  This is troubling because the docs clearly state RemoteCacheManager is an "expensive" object and recommend only having one in the application.


      Digging in to the code a (I'm using Ininispan 8) it looks like the setting is only used when creating a remote cache:


         private <K, V> RemoteCacheImpl<K, V> createRemoteCache(String cacheName) {

            switch (configuration.nearCache().mode()) {

               case INVALIDATED:

                  return new InvalidatedNearRemoteCache<>(this, cacheName,


               case DISABLED:


                  return new RemoteCacheImpl<>(this, cacheName);




      So could we have an overload of getCache that takes a NearCacheMode to override the global config?  Or is there some other reason why it needs to be part of the static config?


      In the meantime is the recommendation for me to use to RemoteCacheManagers, or is there another way I've overlooked?