The <cacheModel> tag provides a readOnly attribute. This attribute is simply an indicator that provides instruction to the cache model, telling it how it should retrieve and store the cached object.
Setting this attribute to true does not prevent retrieved objects from having their contents altered. When specifying a cache as read only, you tell the cache model that it is allowed to pass back a reference to the object that exists in the cache because it is not going to be altered by the application that is requesting it.
If the readOnly attribute is set to false, this ensures that more than one user does not retrieve the same instance of a cached reference.
The readOnly attribute works in conjunction with the serialize attribute. It is important to understand how these two attributes work together.
The serialize attribute
The serialize attribute is used to instruct how cached objects are returned.
When serialize is set to true, each object requested from the cache is returned as a deep copy. This means that the object you retrieve from the cache will have an identical value but will not be the same instance. This ensures that the actual version that is stored in the cache is never returned.
It is important to call attention to the fact that this is not serialization as most would think of it. The objects do not get serialized to disk. This is memory-based serialization that creates deep copies of the cached objects that are in memory.
Summary of readOnly and serialize attribute combinations
0 comments
Post a comment