2 Replies Latest reply on Oct 6, 2014 5:15 AM by Paris Apostolopoulos

    Do I need LockType.READ when accessing infinispan Cache instances for (get /put)

    Paris Apostolopoulos Newbie

      Hello currently I am initializing  my caches using a @Startup EJB 

       

      @Singleton(name="CacheManager")
      @Startup
      @Lock (LockType.READ)
      public class CacheManager{
      
      
          /**
           * We are in Library mode, infinispan's cache Manager
           */
          private EmbeddedCacheManager manager;
      
          /**
           * The caches
           */
          private Cache<String, Map<String, Object>> restSessionCache;
      

       

      Since Cache, is extending ConcurrenctHashMap I am wonding if I can remove the @LockType.Read setting on my Singleton EJB, that is actually implementing a concurrency access control on the EJB/Container level, for methods that will 'pass' the cache to a caller. I am using the CacheManager as a facade so the rest of the code can have access to the cache instance

       

      /**
           * Fetches the instance of the User Session Cache
           * @return Cache<String, Map<String,Object>>
           */
          public Cache<String, Map<String, Object>> getUserSessionCache(){
              return this.restSessionCache;
          }
      

       

       

      So the question is do I need the extra container based 'read or even write locks' on top of the already implemented (internal) concurrency control that the Cache object offers?Or I am missing something?

       

      Many thanks!