Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.cache
Interface ReloadableCache

All Known Subinterfaces:
  Cache

    public interface ReloadableCache

A cache that supports adding entries that know how to reload (rebuild) themselves. The CacheReloader is only used to rebuild the entry when it expires, and does not take effect when the entry is removed for other reasons (such as administrative flush, or if the entry is removed because the Cache's MaxEntries is hit).

See Also
  `Cache`, `CacheReloader`

Method Summary
`CacheReloader` | `getReloader(Object key)` Get the CacheReloader in effect for the given key, or null if no reloader is set.
`Object` | `put(Object key, Object val, CacheReloader reloader)` Put a value into the cache and set a CacheReloader to rebuild the value when it expires.
`Object` | `put(Object key, Object val, long ttl, CacheReloader reloader)` Put a value into the cache, with a specific time-to-live, and a CacheReloader used to rebuild the value when that time-to-live expires.
`void` | `reload(Object key)` Run the reloader explicitly to refresh the value in the cache.
`void` | `setReloader(Object key, CacheReloader reloader)` Set reloader to be run when the cached object has expired.
`CacheReloader` | `unsetReloader(Object key)` Remove the reloader.

Method Detail

### setReloader

    void setReloader(Object key,
                     CacheReloader reloader)

  Set reloader to be run when the cached object has expired. When someone calls get() for this key and the entry has expired, the reloader is run to rebuild the object and refresh the cache rahter than the normal behavior of removing the expired entry (and get returning null). Cached objects without a reloader behave "normally".

  Parameters
    `key` - the cache key to add (or replace) the reloader
    `reloader` - the CacheReloader (or null to remove/unset the reloader for this key
  Throws
    `IllegalArgumentException` - if the cache does not contain the key

### put

    Object put(Object key,
               Object val,
               CacheReloader reloader)

  Put a value into the cache and set a CacheReloader to rebuild the value when it expires.

  Neither the key nor the value can be null. The reloader may be null (in which case no reloader is used and the value will expire in the "normal" way.

  Parameters
    `key` - the key of the entry to create
    `val` - the value to associate with the key
    `reloader` - the CacheReloader to use when the entry expires
  Returns
    `Object` the previous value for the key

### put

    Object put(Object key,
               Object val,
               long ttl,
               CacheReloader reloader)

  Put a value into the cache, with a specific time-to-live, and a CacheReloader used to rebuild the value when that time-to-live expires.

  Neither the key nor the value can be null. The reloader may be null (in which case no reloader is used and the value will expire in the "normal" way.

  Note that it does not make sense to set a reloader and set the ttl to Cache.TTL_NEVER_EXPIRE, since the reloader will never be called in this case (but there is no restriction enforced against doing that).

  Parameters
    `key` - the key of the entry to create
    `val` - the value to associate with the key
    `ttl` - time-to-live, in milliseconds, of the object. This ttl overrides the default ttl for the cache, and applies only to this object.
  Returns
    `Object` the previous value for the key

### getReloader

    CacheReloader getReloader(Object key)

  Get the CacheReloader in effect for the given key, or null if no reloader is set.

  Parameters
    `key` - the key to query
  Returns
    the CacheReloader for that key

### unsetReloader

    CacheReloader unsetReloader(Object key)

  Remove the reloader. Reloaders can also be removed by calling setReloader(key,null). Reloaders are also removed when the cache entry is removed using remove(key).

  Parameters
    `key` - the key for which the reloader is to be removed
  Returns
    the removed (previous) reloader (or null if none was set)

### reload

    void reload(Object key)

  Run the reloader explicitly to refresh the value in the cache. This method blocks until the object is reloaded.

  Parameters
    `key` - the key to be refreshed by the reloaders

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.