For each entity component that uses automatic persistence, enable object caching on the Persistence/Object Cache subtab in the Component Properties dialog box. The settings are:
Enable Object Cache Enables object caching for the component. To enable caching, you must also specify the name of the cache manager component. To use the built-in implementation, enter:
CtsComponents/ObjectCache
The object cache is enabled implicitly if you configure an isolation level that requires the use of the cache. See “Configuring CMP isolation level”.
Cache Name Specifies the name of a cache shared by multiple components. Named caches must be configured as described in “Creating a named cache”.
Cache Size If a named cache is not used, specifies the size of a cache that is dedicated to this component. If you specify both a Cache Name and a Cache Size, the component uses the shared cache specified by the Cache Name property, with the size specified in the named cache property file.
Specify the size in megabytes, kilobytes, or bytes with the syntax shown in the following table:
Syntax |
To indicate |
---|---|
nM or nm |
n megabytes, for example: 512M |
nK or nk |
n kilobytes, for example: 1024K |
n |
n bytes, for example: 536870912 |
Cache Size Check Interval When writing to the object cache, EAServer checks the size of the entry to see if the cache size would be exceeded. If so, least recently used entries are flushed from the cache until there is room for the new entry. The time spent calculating size can adversely affect performance. If you specify a size check interval N, EAServer performs the size calculation on only every Nth entry, and uses a running average size for the interim entries. Setting a size check interval can improve performance. However, if the size of the data varies a lot, setting a size check interval may lead to inaccurate cache size estimations, resulting in memory use beyond the configured cache size. To configure this setting, set the com.sybase.jaguar.component.objectCache.sizeCheckInterval on the Advanced tab in the Component Properties dialog box. The default is 1, which means the size of each entry is checked.
Cache Timeout Specifies how long cache entries remain valid. Components that use a named cache inherit the default timeout from the named cache configuration, but you can override this default. Components that use a dedicated cache have a default timeout of infinity. Specify the timeout in seconds. A value of 0 indicates infinity.
Cache Synchronization For components deployed in a cluster, specifies whether caches on different servers in the cluster are synchronized. Cache synchronization is not necessary if you have configured an isolation level; in that case, the OCC verification queries prevent the use of stale data in transactions. The isolation level setting is easier to configure and provides a higher guarantee of data consistency.
Table 4-4 describes
the synchronization options. Components that use a named cache inherit
the named cache’s sync
property;
the inherited setting can be overridden by setting the component
property.
Option |
Explanation |
---|---|
None |
(The default.) Indicates no synchronization is performed. This value is appropriate if the component is not deployed in a cluster, you have configured a component isolation level, or the cache timeout provides adequate read consistency for transactions. |
Mirror |
Replication without transactional consistency. This value is appropriate for entity components that maintain transient data (that is, the data is not saved to persistent database). If you use this option, you must configure mirror pairs for your cluster as described in “Cluster configuration for in-memory failover” in the EAServer Programmer’s Guide. |
Replicate |
Replication with transactional consistency. For updates, the complete instance state is replicated between servers. |
Invalidate |
Replication with transactional consistency.
For updates, the instance state is not replicated. Rather, updates
are propagated by refreshing the cache entry from the remote database.
This value may yield better performance than the
In this case, the overhead of replicating instance state may exceed that of refreshing each cache from the database. |
Cache synchronization requires a working message service
If using object caching in a cluster, make sure the EAServer
message service is configured and running on each server. The cache
manager uses the message service for cache synchronization between
servers. Chapter 8, “Setting
up the Message Service,” in the EAServer
System Administration Guide describes how to run the
message service.
Creating a named cache
If you want a cache to be shared by multiple components, finder methods or ejbSelect methods, you must create a named cache as follows:
If the Repository/ObjectCache directory does not exist under your EAServer installation, create it.
Create a text file in the Repository/ObjectCache directory named Cache.props, where Cache is the cache name used in component properties.
Add lines as shown below to configure the cache properties. All properties are optional. If not set, the default values apply:
com.sybase.jaguar.objectcache.size=size-value com.sybase.jaguar.objectcache.timeout=timeout-value com.sybase.jaguar.objectcache.sync=sync-method
These values correspond to the component object caching properties, as described in the table below. Each cache property uses the same value syntax as the corresponding component property:
Named cache property |
Component property |
---|---|
|
Cache Size. If not specified, the default is unlimited. |
|
Cache Timeout. If not specified, the default is infinity. |
|
Cache Synchronization |
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |