2 Replies Latest reply: Mar 8, 2013 3:45 AM by 754801 RSS

    Local Cache Semantics

    754801
      Hi,
      I have a newbie question on how LocalCache works. I am guessing we can do size based eviction on LocalCache also. Is it legal to mutate the cache values outside of the cache since I get the reference to the value when I do a cache.get()? If yes, how does Coherence track the size changes of the local caches? Also how does it provide cache notifications when the objects are mutated and not doing an explicit put()?

      Thanks
      SKR
        • 1. Re: Local Cache Semantics
          Jonathan.Knight
          Hi,

          Assuming you are using POF then on the cluster the values in the Local Cache will be a Binary key and a Binary value. As Binary is immutable it is not possible to change the value referenced by the Local Cache.

          Now, this changes for some types of cache where the value is held deserialized, for example a CQC, where you can mutate the value and this mutates the underlying value in the cache. This is exactly the same thing that happens in pretty much every Map implementation in Java though.

          JK
          • 2. Re: Local Cache Semantics
            754801
            Thanks for the reply, Jonathan. I am not using POF in my local cache and it is not a clustered like in CQC or near cache. It is a stand alone localcache embedded in my tomcat JVM. I did verify that it works in the same manner as a java.util.Map but I was wondering how the size (in bytes) based eviction and notifications work in this case. For e.g. when I mutate an object graph after I do a get and keep holding on to it in my client thread, how do you determine whether it is a candidate for eviction, etc? Do you also periodically traverse through each object and all its child references in order do evictions so my cache size is always kept under the high watermark? Hope this makes sense in the context of LocalCache and I am not missing something obvious in terms of its behavior.

            Thanks
            Sairam