Chapter 8. Caching

Table of Contents

Introduction
Automatic Caching
Database Object Caching
Custom Caching
Clustered or Distributed Environments
Conclusion
Contributors

Note

If you find this EDG documentation helpful please consider DONATING! to keep the doc alive and current.

 Maintainer:David Lloyd

Expresso offers built-in caching ability, designed to be completely configurable for different deployment situations. Caching is handled via a CacheManager object, designed to maximize performance without causing out-of-memory problems by trying to hold too much in cache at once.

Introduction

The Expresso framework includes a caching system build into the framework. This caching layer can cache just about anything from dbobjects and configuration parameters to custom build caches. This caching layer provides fast lookups for frequent used data and provides an alternative for make frequent database calls. The actual class that controls the caching is called the CacheManger and call be found in the expresso tree underunder expresso/core/cache/CacheManager.

The CacheManger works by providing a general-purpose class that handles both ordered caches and unordered caches. The ordered caches are made possible by storing the data as a vector of objects. The unordered caches are supported by placing the data into hashtables. Also, the CacheManger only works if the amount of free memory is above 10%. The free memory is the memory in the Java Virtual Machine, and can vary from moment to moment.

The CacheManager is fully independant of even the DBObject components, so you can use it to your heart's content independently of using Expresso. For example, there's an example in com.jcorporate.expresso.core.dbobj.SecuredDBObject of the security system creating it's own cache to significantly speed table lookups for security checking.

The 5.X releases includes work to the Cache system to make it more scaleable and robust.

Automatic Caching

Objects commonly accessed, such as configuration values and setup values and security data are automatically cached, but the cache is automatically updated when the corresponding item is changed in the database, so you never have to worry about "stale" data in the cache.

Database Object Caching

Database objects (usually representing data in a table in a database) can also be cached, and you can control the number of cache entries for each object, using more caching for items more frequently used by your application.

The cache manager also performs automatic memory management by keeping a monitor of the amount of memory available and used, and automatically clearing the least-frequently used caches when memory drops below a configurable threshold.

Custom Caching

Your application can use the CacheManager to cache any custom information required, allowing you to selectively improve performance without sacrificing the accuracy of data.

Clustered or Distributed Environments

Caching can even be used in a distributed environment, as the cache manager can be set up to allow synchronization with caches from other servers or contexts, guaranteeing the most current data to your users while still offering the performance benefits of the cache.

Conclusion

Contributors

The following persons have contributed their time to this chapter:

  • Mike Nash

  • Sandra Cann

Note

Was this EDG documentation helpful? Do you wish to express your appreciation for the time expended over years developing the EDG doc? We now accept and appreciate monetary donations. Your support will keep the EDG doc alive and current. Please click the Donate button and enter ANY amount you think the EDG doc is worth. In appreciation of a $35+ donation, we'll give you a subscription service by emailing you notifications of doc updates; and donations $75+ will also receive an Expresso T-shirt. All online donation forms are SSL secured and payment can be made via Credit Card or your Paypal account. Thank you in advance.

Copyright © 2001-2004 Jcorporate Ltd. All rights reserved.