When the client cache cannot be used, retrieve a deep copy to acquire a fresh instance of an object. Enable the in-process network cache to reduce network overhead when retrieving deep copies.
Deep Copies and the Network Cache
Some object access patterns may prohibit usage of the client cache (see Usage Guidelines). There are two ways to return deep copies from read operations:
- On a cache-wide basis, disable the client cache by setting its capacity to zero in your config file or through CacheBuilder.SetClientCache. Read operations will then always return a fresh, newly deserialized instance of an object.
- To retrieve a deep copy for individual read calls, pass a ReadOptions struct to the read method with its ClientCacheUsage property set to ReturnDeepCopy.
Improving Deep Copy Performance
The Scaleout.Client library can be configured to use a low-level network cache of serialized objects to improve deep copy performance. By default, this cache is disabled. It can be enabled at the cache level using the
networkCacheSizeBytes option in your config file or the SetNetworkCacheSize(Int64) method when building a Cache.