OFBiz has a really neat feature that, if used correctly, can drastically increase the application's performance by dramatically cutting down the number of queries sent to the database. It does this by using what is known as the Entity Engine Cache. The principle of a cache is to act as an easily accessible store of data. This store is first checked and if the required data is there then it is retrieved immediately. If the required data is not present in the cache then it is obtained, in the case of the Entity Engine Cache, via a database lookup. The data is then placed into the cache. The next time the same information is required, the cache is again checked and the data is returned immediately from the cache.
Since the cache is held in memory, the lookup is now performed much faster.
Using the cache is easy. Where we would normally use the GenericDelegator
object's findByPrimaryKey()
method to return one record, we use findByPrimaryKeyCache()
. The Cache
appendage...