Interface CacheReloader

All Known Subinterfaces:

public interface CacheReloader

Reloader for cached objects. A CacheReloader can be associated with an object in the cache using either ReloadableCache.put() or ReloadableCache.setReloader().

Normal cache operation is to check for entry expiration when get() is called. If the entry has no CacheReloader, get will remove expired entries and return null. This is usually taken as a signal for the calling program to build the item. But if the entry has a CacheReloader, the Cache.get() method will use it to rebuild expired items rather than returning null.

See Also

Method Summary
 Object reload(String cacheName, Object key, Object oldValue)
          This is the method used to rebuild objects for the cache.

Method Detail


Object reload(String cacheName,
              Object key,
              Object oldValue)
This is the method used to rebuild objects for the cache. It is called whenever the cache detects that an item has expired and needs to be reloaded. An implementaion of this method should return the new object that will replace the expired object in the cache.

The method arguments are probably not necessary in most cases, but are here to allow you to implement a single CacheReloader that can be reused for multiple cached objects.

cacheName - the name of the cache that is requesting the reload
key - the name of the key that is to be reloaded
oldValue - the current (expired) value in the cache
the new value to be put in the cache. Returning null has the effect of causing the key to be removed from the cache.

Copyright © 2011, Oracle. All rights reserved.