With cloning enabled, Geode does a deep copy of the object, using serialization. You can improve performance by implementing the appropriate
clone method for your API, making a deep copy of anything to which a delta may be applied.
The goal is to significantly reduce the overhead of copying the object while still retaining the isolation needed for your deltas.
You configure delta propagation on the server side as well as client. For information on the server and delta propagation, see Delta Propagation.
cloning-enabled property is a region attributes boolean, configured in the
cache.xml, that affects how
fromDelta applies deltas to the local client cache. When
true, the updates are applied to a clone of the value and then the clone is saved to the cache. When
false, the value is modified in place in the cache. The default value is
Cloning can be expensive, but it ensures that the new object is fully initialized with the delta before any application code sees it.
- It is possible for application code to read the entry value as it is being modified, possibly seeing the value in an intermediate, inconsistent state, with just part of the delta applied. You may choose to resolve this issue by having your application code synchronize on reads and writes.
- Geode loses any reference to the old value because the old value is transformed in place into the new value. Because of this, your
CacheListenersees the same new value returned for
- Exceptions thrown from
fromDeltamay leave your cache in an inconsistent state. Without cloning, any interruption of the delta application could leave you with some fields in your cached object changed and others unchanged. If you do not use cloning, keep this in mind when you program your error handling in your
Enabling Cloning in cache.xml
<region name="exampleRegion"> <region-attributes refid="CACHING_PROXY" cloning-enabled="true" pool-name="examplePool"/> </region>
Enabling Cloning (C++)
RegionFactoryPtr regionFactory = cachePtr->createRegionFactory(CACHING_PROXY); RegionPtr regionPtr = regionFactory ->setCloningEnabled(true) ->create("myRegion");