|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.constructs.blocking.BlockingCache net.sf.ehcache.constructs.blocking.SelfPopulatingCache
public class SelfPopulatingCache
A selfpopulating decorator for Ehcache
that creates entries on demand.
BlockingCache.get(java.io.Serializable)
calls.
Thread safety depends on the factory being used. The UpdatingCacheEntryFactory should be made
thread safe. In addition users of returned values should not modify their contents.
Field Summary | |
---|---|
protected CacheEntryFactory |
factory
A factory for creating entries, given a key |
Fields inherited from class net.sf.ehcache.constructs.blocking.BlockingCache |
---|
cache, LOCK_NUMBER, locks, timeoutMillis |
Constructor Summary | |
---|---|
SelfPopulatingCache(Ehcache cache,
CacheEntryFactory factory)
Creates a SelfPopulatingCache. |
Method Summary | |
---|---|
Element |
get(java.lang.Object key)
Looks up an entry. |
void |
refresh()
Refresh the elements of this cache. |
protected void |
refreshElement(Element element,
Ehcache backingCache)
Refresh a single element. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.ehcache.Ehcache |
---|
toString |
Field Detail |
---|
protected final CacheEntryFactory factory
Constructor Detail |
---|
public SelfPopulatingCache(Ehcache cache, CacheEntryFactory factory) throws CacheException
CacheException
Method Detail |
---|
public Element get(java.lang.Object key) throws LockTimeoutException
get
in interface Ehcache
get
in class BlockingCache
key
- an Object value
LockTimeoutException
- if timeout millis is non zero and this method has been unable to
acquire a lock in that timeEhcache.isExpired(net.sf.ehcache.Element)
public void refresh() throws CacheException
BlockingCache
and act directly on the backing Ehcache
.
This way, BlockingCache
gets can continue to return stale data while the refresh, which
might be expensive, takes place.
Quiet methods are used, so that statistics are not affected.
Configure ehcache.xml to stop elements from being refreshed forever:
CacheException
protected void refreshElement(Element element, Ehcache backingCache) throws java.lang.Exception
element
- the Element to refreshbackingCache
- the underlying Ehcache
.
java.lang.Exception
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |