
590
DEVELOPING
COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Las
t
upda
te
d 8/5/2010
One important thing to understand here is that
batchsize
here does not mean that 10 artworks are loaded at one
time for a artist. It actually means that 10 artwork collections (artworks for 10 artists) are loaded together.
When you call
getarts()
on the first artist, artworks for 9 other artists are also fetched along with the one that was
asked for.
The value for
batchsize
attribute should be chosen based on the expected number of proxied objects or
uninitialized collections in the session.
Caching
Caching is extensively used for optimizing database applications and effectively reducing traffic between the database
and the application.
ColdFusion ORM supports two levels of caching:
•
Session level
•
Secondary level
Session level cache
Objects that are loaded from the database are always cached in the ORM Session as long as the session is open. When
EntityLoad
is called to retrieve an object in a session for the first time, ORM fetches the data from the database and
constructs the object. In any subsequent call to load the same object in the same session, ORM fetches the object from
the session cache. To forcefully retrieve the object from the database,
EntityReload
should be called on the object.
For more details on ORM Sessions and its lifecycle, see “
ORM session management
” on page 595 and “
Architecture
”
on page 537.
Secondary level cache
ColdFusion provides the ability to store the data that is retrieved from the database in secondary cache. The contents
in secondary cache live longer than the life-time of a session. It can also be the life-time of the process or in-definite
(disk-caching), depending on the ability of the secondary cache provider. The cache can also be used in a distributed
environment depending on the ability of the secondary cache provider.
An important difference between session level cache and secondary level cache is that the session level caches the whole
object but the secondary level caches only the data.
Secondary level cache can be leveraged by using an external cache provider with ColdFusion ORM. EHCache,
JBossCache, OSCache, SwarmCache, and Tangosol Coherence Cache are some popular secondary cache providers,
which can be plugged into Hibernate.
ColdFusion uses EHCache as the default secondary cache provider. EHCache is a distributed caching solution that
supports memory and disk-based caching. EHCache can be configured using a configuration file. Different cache
regions can be defined in the configuration file. Each cache region has its own configuration that specifies details
including the number of elements it can store, eviction policy, time to live (ttl), and idle time.
ehcache.xml is available in the following location:
CF_root
\lib\. For details of the properties in the ehcache.xml, refer
to the documentation available at the following URL:
http://ehcache.org/
The following is a sample EHCache configuration file (
ehcache.xml
):
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...