|
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 |
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).
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 |
---|
void setReloader(Object key, CacheReloader reloader)
key
- the cache key to add (or replace) the reloaderreloader
- the CacheReloader (or null to remove/unset the reloader
for this key
IllegalArgumentException
- if the cache does
not contain the keyObject put(Object key, Object val, CacheReloader reloader)
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.
key
- the key of the entry to createval
- the value to associate with the keyreloader
- the CacheReloader to use when the entry expires
Object
the previous value for the keyObject put(Object key, Object val, long ttl, CacheReloader reloader)
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).
key
- the key of the entry to createval
- the value to associate with the keyttl
- time-to-live, in milliseconds, of the object. This ttl
overrides the default ttl for the cache, and applies only to this
object.
Object
the previous value for the keyCacheReloader getReloader(Object key)
key
- the key to query
CacheReloader unsetReloader(Object key)
key
- the key for which the reloader is to be removed
void reload(Object key)
key
- the key to be refreshed by the reloaders
|
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 |