3 Replies Latest reply on Apr 6, 2012 4:46 AM by Dan Berindei

    updates on remote cache

    venkataratnam teki Newbie



      I have 2 laptops and and i started hotrod server on Node1.


      From the other system(which is in the same network),  i did the following..


      RemoteCacheManager rm = new RemoteCacheManager("node1ip", port);


      RemoteCache<string, Student> rcache  =rm.getCache("studentCache");


      Student st = rcache.getStudent(string);


      If i have the same jar(containing Student class) in classpath of node2, will this work?


      If this works, 


      st.setName("new name");


      Will, changing the property of Student in node2, will also update the remote cache?



        • 1. Re: updates on remote cache
          Nag Ch Newbie

          In order to update on remote cache you need do cache.put(st).

          • 2. Re: updates on remote cache
            venkataratnam teki Newbie



            So, its not like in local cache? in local cache, i do not need to do cache.put(k,v) . Probably value will be stored as a reference. So, if we do the below, it will update the object in the cache..


            Book b = cache.get("key");

            b.updateSomeProperty("new property");


            and if i do cache.get("key") now, i will get the updated book object..


            So, my doubt is, does this hold good in remote cache also??

            • 3. Re: updates on remote cache
              Dan Berindei Expert

              On the local node Infinispan does not copy the inserted objects and keeps a reference to the original object instead (unless you enable storeAsBinary). So all the changes made to those objects are automatically visible in the cache, but that is just an accidental effect of how Infinispan stores values - there isn't any effort to track changes to your objects and update the values in the cache.


              The remote nodes obviously can't hold a reference to your objects, so they won't see any changes this way. The old JBossCache project had a "POJO Edition" that would track changes to objects and automaticall update the copies on all the cluster nodes, but it hasn't been ported to Infinispan.