Many optimizations rely on in-memory caching of database query result sets. EAServer has two cache mechanisms for caching container managed field data and query results:
The object cache stores results from findByPrimaryKey method invocations and the associated entity bean instances.
The query cache stores results returned from other finder methods and query methods.
EAServer creates and manages these caches internally. There are no configuration entity types to configure them explicitly; rather, they are configured implicitly by your CMP table and field mapping configuration settings.
Caching can improve performance by minimizing the number of database select queries required for ejbLoad operations, finder method invocations, and ejbSelect method invocations. Most database applications are governed by the 80:20 rule: 80% of users access 20% of the data. Object caching increases performance and scalability by allowing faster access to the most recently used data.
Assuming that the database access is the principal bottleneck, the expected performance gain falls in these ranges, depending on the ratio of update to read-only transactions:
1.5 to 2 times faster for applications where most transactions are updates.
3 to 30 times faster for applications where most transactions are read-only.
Besides the transaction mix, the actual performance gain depends on:
The size of the database table
The size of the object and query caches
The cache time out value
In summary, the best use case for caching is data that is static. If the data changes often, the overhead of updating caches can outweigh the performance benefits of caching. If the data is updated too frequently, soft locking or hard locking may yield better performance. Furthermore, the data consistency requirements dictate how cached data can be used. Decide how much consistency you require, then optimize within those constraints.