1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
<html>
<head>
<title>OSCache and Hibernate</title>
</head>
<body>
<p><a href="http://www.hibernate.org">Hibernate</a> is a powerful, ultra-high
performance object/relational persistence and query service for Java.
Hibernate lets you develop persistent objects following common Java idiom -
including association, inheritance, polymorphism, composition and the Java
collections framework. Extremely fine-grained, richly typed object models
are possible.</p>
<p>Hibernate 2.1 features support for plugin cache providers and is
designed to integrate with distributed caches (2.1 also implements more
aggressive use of the cache).
<b>net.sf.hibernate.cache.CacheProvider</b> is the extension point for
user-defined cache integration.</p>
<p><a href="http://www.hibernate.org/6.html">Hibernate 2.1.1</a> or
higher is required.</p>
<h3>hibernate.cache.provider_class</h3>
<p>OSCache and Hibernate 2.1 integrate though <b>OSCacheProvider</b>. To
enable OSCache in Hibernate's configuration, add the following line to
hibernate.cfg.xml:</p>
<pre>
<property name="hibernate.cache.provider_class"><b>net.sf.hibernate.cache.OSCacheProvider</b></property>
</pre>
<p>The default refresh period is
<a href="http://www.opensymphony.com/oscache/api/com/opensymphony/oscache/base/CacheEntry.html#INDEFINITE_EXPIRY">CacheEntry.INDEFINITE_EXPIRY</a>.
The first time a cacheable query is done, the cache has no effect on
speed. On the second and successive queries, the cache will be populated
and available to be hit.</p>
<p>NOTE: object identifiers must have well-behaved <tt>toString()</tt> methods.</p>
<h3>Configuration</h3>
<p>To modify the refresh period, CRON expression or maximum cache
capacity, add the region configuration to your oscache.properties file,
as demonstrated below:</p>
<pre>
com.mypackage.model.Customer.refresh.period = 4000
com.mypackage.model.Customer.cron = * * 31 Feb *
com.mypackage.model.Customer.capacity = 500
</pre>
<p>The <code>com.mypackage.model.Customer</code> is Hibernate's internal
<b>cache region</b>, which defaults to the classname, but which can be
specified in the Hibernate mapping files (region attribute of class-
cache element or collection-cache element).</p>
</body>
</html>
|