Adobe COLDFUSION 9 Manual page 598

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Cache the association data of a persistent object
In this case, the primary key of the associated objects are cached. It does not cache the objects loaded as part of the
association unless caching is enabled for those objects. To cache an association, specify the following attributes on the
association property.
: Defines the caching strategy.
cacheuse
: Defines the name of the cache region to be used by the secondary cache provider. If you do not specify
cachename
a region name for the association property, the <comoponent_name>.<property_name> is considered as the cache
name. In case a region is not specified in the configuration file, a region is automatically created with the default
configuration.
For example:
<cfproperty name="art" fieldtype="one-to-many" cfc="CArt" fkcolumn="ArtID"
cachename="ArtistArts" cacheuse="read-only">
Cache query data
In this case, the results of queries that are executed by
the secondary cache. To enable caching query data, pass "
the options struct of the methods. If you do not specify the
It is recommended that you to specify the
For example:
availableArts = ORMExecuteQuery("from CArt where issold=0", {}, false, {cacheable=true,
cachename="availableArtsQuery"});
Secondary cache example using EHCache
Step 1: Set the following in
Application.cfc
<cfset this.name="Caching_Example">
<cfset this.datasource="cfartgallery">
<cfset this.ormenabled="true">
<cfset this.ormsettings.secondarycacheEnabled=true>
<cfset this.ormsettings.cacheProvider= "ehcache">
<cfset this.ormsettings.cacheConfig="ehcache.xml">
Step 2: Define the cache settings in the CFCs.
CArtist.cfc
<cfcomponent persistent="true" schema="APP" table="Artists" cachename="artist"
cacheuse="read-only">
<cfproperty name="artistid" fieldtype="id"/>
<cfproperty name="firstname"/>
<cfproperty name="lastname"/>
<cfproperty name="state"/>
<cfproperty name="art" fieldtype="one-to-many" cfc="CArt" fkcolumn="ArtID"
cachename="ArtistArts" cacheuse="read-only">
</cfcomponent>
CArt.cfc
<cfcomponent persistent="true" schema="APP" table="Art">
<cfproperty name="artid" generator="identity" fieldtype="id"/>
<cfproperty name="artname"/>
<cfproperty name="issold"/>
</cfcomponent>
ORMExecuteQuery()
cacheable=true
, the query is cached in the default query cache.
cachename
so that you can control eviction.
cachename
:
Last updated 8/5/2010
or
methods are cached in
EntityLoad()
" and
"cachename='cachename'
593
values in

Advertisement

Table of Contents
loading

Table of Contents