Product Documentation : Ehcache Developer Guide : Cache Loaders : About Cache Loaders
About Cache Loaders
A CacheLoader is an interface that specifies load() and loadAll() methods with a variety of parameters. CacheLoaders are incorporated into the core Ehcache classes and can be configured in ehcache.xml. CacheLoaders are invoked in the following Cache methods:
*getWithLoader (synchronous)
*getAllWithLoader (synchronous)
*load (asynchronous)
*loadAll (asynchronous)
The methods will invoke a CacheLoader if there is no entry for the key or keys requested. By implementing CacheLoader, an application form of loading can take place. The get... methods follow the pull-through cache pattern. The load... methods are useful as cache warmers.
CacheLoaders are similar to the CacheEntryFactory used in SelfPopulatingCache, however SelfPopulatingCache is a decorator to Ehcache.
CacheLoaders can be set either declaratively in the ehcache.xml configuration file or programmatically. If a CacheLoader is set, it becomes the default CacheLoader. Some of the methods invoking loaders enable an override CacheLoader to be passed in as a parameter. More than one CacheLoader can be registered, in which case the loaders form a chain which are executed in order. If a loader returns null, the next in chain is called.
Copyright © 2010-2015 Software AG, Darmstadt, Germany.

Product Logo |   Feedback