Object Broker
Broker Overview
The object broker is a super piece of caching technology for the integrated ORM of FarCry Core. In simple terms it speeds up the access to data in the database by only retrieving the data once, then using in memory storage to provide fast access for subsequent requests. You really want to turn this on. The goodness provided is only limited by the the memory available to your ColdFusion instance.
Objectbroker manages the population and refreshing of its cache. You don't really need to do anything more than activate the service for the specific content types you desire.
In addition to specific database calls, object broker can also manage caching of all views. A view is like a fragment of output, such as HTML. Generally a page request is made up of one or more views. Objectbrokers webskin cache will even keep track of embedded views, flushing all the relevant views whenever a relevant content item is changed. This ensures that your changes are directly reflected in the view without having to be involved in any complex cache management.
How to activate the ObjectBroker
The object broker is activated by adding component level metadata to your content type.
<cfcomponent extends="farcry.core.packages.types.versions" displayname="Article" hint="Standard article used in the site." bObjectBroker="true" objectbrokermaxobjects="10000" lObjectBrokerWebskins="display*">
bObjectBroker
True activates object level caching for the specific content type. The default if you do not specify this attribute is false.
objectbrokermaxobjects
The maximum number of objects to be held in the broker for this content type. The default if you do not specify this attribute is 100. Typically you want to set this to a number that is high enough to hold all the records for this content type. The only reason not to is if you lack enough physical memory on the ColdFusion instance to accommodate them.
lObjectBrokerWebskins
A list of webskins that should be cached. The default timeout for any webskin cache is 1400 minutes (or 24 hours). This seems like a long time, but remember they get automatically flushed if content within the view is updated.
You can list the webskin templates by name, for example:
lObjectBrokerWebskins="displayTeaserFeature,displayPageStandard"
You can list the webskin templates using a wildcard, for example:
lObjectBrokerWebskins="display*"
You can nominate a specific timeout in minutes for each template, for example:
lObjectBrokerWebskins="displayTeaserFeature:30,displayPageStandard:60"
Dealing Pagination & other URL changes
In some cases you need the view to respond to changes on the URL. For example in the case of a paginated result set, you may be changing the displayed list of teasers based on a URL parameter such as &pg=2 This is often awkward for caching regimes as you really need to use a hash of the query string in order to be sure you are looking at the right cache.
You can have webskin caches dynamically keyed by a hash of the pages URL by including the @@hashURL template level metadata, for example:
<!--- @@displayname: Article Pagination Rule ---> <!--- @@description: A bit of blurbage about what this rule can do. ---> <!--- @@author: Mat Bryant (mat@daemon.com.au)---> <!--- @@hashURL: true --->
Note: you only have to include this directive inside the webskin that responds to the URL parameter. If this webskin is embedded inside another webskin the system will automatically determine what additional caches would need to be flushed in the event of a change in URL parameter.
Object Broker Webtop Report
You can check which content types have been activated for the object broker by running the Objectbroker Report in the webtop Admin section. This should indicate those content types using the objectbroker, their maximum threshold and the current number of objects in the broker.
Basic process flow
- on fourq.getData() calls
- check typename.objectpool for UUID
- if present
- return struct
- if not,
- make dbgateway call
- check if room in objectpool
- purge/update aobjects FIFO list as required
- update objectpool with object struct
- return struct
- update cache stats (no cache stats implemented at this time 20070505)
- if present
- check typename.objectpool for UUID
- return object struct to content type call exactly as per original
In memory structure of object broker
application |
||||
- |
objectbroker |
|||
- |
- |
typename |
||
- |
- |
- |
objectpool |
(structure, keyed by OBJECTID, of content item structures) |
- |
- |
- |
objectpool |
stobj |
- |
- |
- |
objectpool |
stwebskins(structure keyed by template name and/or url hash |
- |
- |
- |
aObjects |
(manage object pooling by FIFO) |
- |
- |
- |
maxobjects |
(maximum number of objects to cache) |