You've learned that the business objects should not store any of the information they receive from their data source. This task is performed by a dedicated caching layer.
Caching in the CoreMedia CAE has a number of important properties:
Caching is defined outside the business objects.
Caching is achieved by building a subclass of a business class, materializing properties into actual fields and storing an instance of this subclass.
Cached objects have the same interface as the non-caching business objects so that one can develop against non-cached versions first and does not need to change the code later.
A set of public bean properties of the business object is subject to caching.
Cached objects can be aggregated: one cached object can store a direct object reference to another cached object. Once retrieved from the cache, this association can be navigated without further synchronization or cache lookups. This is important for fast rendering.
It is possible to cache different sets of properties of the same business object; "more" or "different" properties of this object can be used in different contexts. Often it is not sensible to cache all properties of an object for two reasons: if one property set is significantly smaller than another or faster to compute (for example, only the metadata), it may be worth the overhead of caching two objects. The second – more important – reason is dependencies: if one representation acquires fewer dependencies than another and provides all properties needed in a certain context it should be cached separately (for example, "uses only content properties from the CMS but not the database"). Especially different amounts of aggregation are a concern here (for example, when the object cached in the parent property in turn depends on a different content object).
Cache invalidation is dependency-driven, that is, a cache value has associated dependencies on external values and is invalidated if one of these changes. This happens automatically for dependencies to the content repository.
The CoreMedia CAE caching layer gives you the option to define several cached representations for one business object. It is possible to distinguish the following:
The properties of the business object which are cached
For properties that refer to other business objects, which cached representation, if any, should be aggregated
Such a definition is called a data view of an object.
Caution | |
---|---|
Do not confuse this term with the term view used in rendering: a data view is an object that extracts and aggregates source data in the cache. A view is a method of rendering an object. Of course, data views and views are related: in order to render a view efficiently, the displayed object should provide its data sufficiently fast; possibly using a data view from the cache. |
For example, you can define
"fully cached" for display, for a data view that contains a page's description, its content and its parent page "for linking"
"for linking", a data view of a page that only contains its description