5 Replies Latest reply on Jul 19, 2018 4:37 PM by Sueleyman Vurucu

    Handling with DAOCacheStore

    Sueleyman Vurucu Expert

      I have successfully  setup infinispan 9.3 in Wildfly 11 in embedded mode with a custom cache store that access my entity dao. so far so good everything working well.

      But I thre are some clarification points for my understanding of chaching with infinispan.

       

      1.

      The part of wirte through implementation

       

          @Override
          public void write(MarshalledEntry<? extends K, ? extends V> entry) {
              final byte[] bytes = toBytesFromWarrped(entry.getValue());
              try {
                  Entitiy o = (Entitiy )ctx.getMarshaller().objectFromByteBuffer(bytes);
                   o =   ServiceUtil.getEntityDaoLocal().makePersistent( o);
                   ctx.getCache().replace(o.getName(),o) ;
              } catch (Exception e) {
                  throw new PersistenceException(e);
              }
          }
      

       

      Ist this way ok to update the cache entry on this way? The reason for the replacement is that the ID of the new entity is set by jpa provider after it passes the entitymanager. For that reason I assume, JPACacheStore from infinispan does not allows @GeneratedValues for Id fields.

       

      2. Is there a way to lock cache entries for read access like a database write lock?

       

      3. What is the infinispan approch to start with warm caches. ( Do an inital fill if the cache created for the first time )