Java Reference
In-Depth Information
kodo.DataCache: true
kodo.RemoteCommitProvider: sjvm
The kodo.DataCache property enables the PersistenceManagerFactory -level
cache and also specifies the cache configuration, such as its size and how long
cached items should remain in the cache. You can also configure multiple caches
with different configurations. The kodo.RemoteCommitProvider property speci-
fies how to broadcast change invalidation messages to other cluster members
when objects are modified. A value of sjvm is used in a single JVM configuration.
When Kodo's PersistenceManagerFactory -level cache is enabled, all classes
will be cached by default. You can configure caching behavior for individual
classes, however, using metadata extensions. The data-cache extension specifies
whether instances of this class should be cached and which cache to use. The
data-cache-timeout extension specifies how long an instance should be
cached; a timeout of -1 means indefinitely. Here is an example:
<class name="Restaurant" identity-type="application">
<extension vendor-name="kodo"
key="data-cache-timeout"
value="3600000"/>
</class>
This metadata specifies that the Restaurant class should be cached for at most
one hour.
Kodo JDO , like other JDO implementation, also provides methods for evicting
objects from the PersistenceManagerFactory -level cache. An application
removes an single object from the cache by calling DataCache.remove() and
removes a collection of objects by calling DataCache.removeAll() . An applica-
tion often needs to evict stale objects from the cache if it updates the database by
using, for example, i BATIS or JDBC .
Using the PersistenceManagerFactory-level cache
To cache only the restaurant-related classes— Restaurant , MenuItem , and Time-
Range —in the Kodo JDO PersistenceManagerFactory -level cache, we would
enable the cache and disable caching for the other domain model classes, such as
PendingOrder and PendingOrderLineItem . We would also have to turn off any
eager loading of the restaurant-related classes to ensure that the Persistence-
ManagerFactory -level cache is used. Kodo would then just load the pending
order and its line items using a single SQL statement. The JDO implementation
retrieves the restaurant and menu item objects referenced by the pending order
 
 
 
Search WWH ::




Custom Search