Defines interfaces and constants for general purpose static and dynamic cache components.

Package Specification

Many applications require some sort of caching facilities. For example, a configuration component that loads values from a property file or a database needs to cache the retrieved configuration values in memory to speed up the process of serving configuration values to the clients. In a static scenario the values are loaded once at the application startup and cached for the lifetime of the application process. On the other hand, the values can be reloaded at runtime if they change in the back end storage database or property file(s).

In the latter case, a component that wishes to be updated dynamically must implement IDynamicCache interface so that data loading components that implement IDynamicCacheRefresher interface can load fresh values from the back end storage and update the component with the data loaded. This decouples component service behavior from data access logic implemented in IDynamicCacheRefresher compliant refresher components, which can be easily reused.

Use example

A dynamic cache can be refreshed in the following way
public class DynamicConfig implements IDynamicCache
{
  private IDynamicCacheRefresher m_oRefresher = new MyDatabaseRefresher();

  private void loadConfig()
  {
    m_oRefresher.refresh(this);
  }

  public void update(Map mapUpdates)
  {
    // mapUpdates contans all the new values loaded by refresher.
    save new updates here
  }
}
@since 12/15/2004