Using method results caching

For stateless components, you can configure method results caching. In this configuration, EAServer caches method return codes using a key composed of the input parameter values. When handling an incoming request, EAServer checks for a valid cached entry. If the cache contains a valid result, EAServer returns the cached return code rather than invoking the business method. To use this feature, your component must satisfy these requirements:

To configure method caching, run the <cacheResult> property task in the Ant user-configuration file for the EJB module that contains the stateless session bean to be configured. To configure a CORBA or PowerBuilder component, perform this configuration on the EJB module that contains the EJB wrapper components for the CORBA package. Here is an example configure-user target that configures a version table:

<target name="configure-user">
  <setProperties component="ejb.components.myjar.MyCompRemote">
    <cacheResult method="getProductInfo(java.lang.Integer)" 
                 cacheSize="100"
                 dataSource="myDataSource"
                 tableVersion="ref_tv.version"
    />
  </setProperties>
</target>

Here is another example that configures a cache timeout:

<target name="configure-user">
  <setProperties component="ejb.components.myjar.MyCompRemote">
    <cacheResult method="getProductInfo(java.lang.Integer)" 
                 cacheSize="100"
                 cacheTimeout="60"
    />
  </setProperties>
</target>

The table below describes the attribute values used in the examples:

Attribute

Description

component

Specifies the name of the DJC component that runs the application component that you want to monitor. Set this depending on the application component type, as follows:

  • For enterprise JavaBeans components, specify the DJC component that corresponds to the remote or local interface. You can read the DJC component names from the EJB module’s Ant configuration file that was generated by deployment.

  • For CORBA and PowerBuilder components, specify the DJC component that corresponds to the remote interface of the EJB session bean that wraps your component. This name is ejb.components.package.componentRemote, where package is the CORBA package name, and component is the component name.

  • For Web components, specify the DJC component that corresponds to the servlet or JSP that the settings apply to. You can read the DJC component names from the Web application’s Ant configuration file that was generated by deployment.

method

Specifies the Java name and signature of the business method. If omitted, the cache configuration applies to all non-void methods in the component.

cacheSize

The maximum number of results that will be held in cache. To avoid overflow, rows are removed from cache using a least-recently-used (LRU) discard strategy. If not specified, the default is 1000.

cacheTimeout

The maximum number of seconds that a result stored in cache will be considered valid. This property should not be used to attempt to control the cache size, because invalid results are only discarded from cache when an attempt is made to access them. A value of zero is interpreted as an infinite timeout. The default is zero.

dataSource

If a version table is required, specifies the name of the data source to connect to the database in which the table is located.

tableVersion

If a version table is required, specifies the table name and the name of the column that contains the version number. For example, ref_tv.version specifies the version column in table ref_tv.