|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.constructs.EhcacheDecoratorAdapter 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 |
---|
timeoutMillis |
Fields inherited from class net.sf.ehcache.constructs.EhcacheDecoratorAdapter |
---|
underlyingCache |
Constructor Summary | |
---|---|
SelfPopulatingCache(Ehcache cache,
CacheEntryFactory factory)
Creates a SelfPopulatingCache. |
Method Summary | |
---|---|
Element |
get(Object key)
Looks up an entry. |
protected static Element |
makeAndCheckElement(Object key,
Object value)
Both CacheEntryFactory can return an Element rather than just a regular value this method test this, making a fresh Element otherwise. |
void |
refresh()
Refresh the elements of this cache. |
void |
refresh(boolean quiet)
Refresh the elements of this cache. |
Element |
refresh(Object key)
Refresh a single element. |
Element |
refresh(Object key,
boolean quiet)
Refresh a single element. |
protected void |
refreshElement(Element element,
Ehcache backingCache)
Refresh a single element. |
protected Element |
refreshElement(Element element,
Ehcache backingCache,
boolean quiet)
Refresh a single element. |
Methods inherited from class net.sf.ehcache.constructs.blocking.BlockingCache |
---|
get, getAllWithLoader, getCache, getLockForKey, getTimeoutMillis, getWithLoader, liveness, load, loadAll, put, put, putIfAbsent, putIfAbsent, putQuiet, putWithWriter, registerCacheLoader, setTimeoutMillis, unregisterCacheLoader |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final CacheEntryFactory factory
Constructor Detail |
---|
public SelfPopulatingCache(Ehcache cache, CacheEntryFactory factory) throws CacheException
CacheException
Method Detail |
---|
public Element get(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.
Note that the refreshed elements will not be replicated to any cache peers.
Configure ehcache.xml to stop elements from being refreshed forever:
CacheException
public void refresh(boolean quiet) 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 if argument 0 is true, so that statistics are not affected,
but note that replication will then not occur
Configure ehcache.xml to stop elements from being refreshed forever:
quiet
- whether the backing cache is quietly updated or not, if true replication will not occur
CacheException
public Element refresh(Object key) 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.
If the element is absent it is created
Quiet methods are used, so that statistics are not affected.
Note that the refreshed element will not be replicated to any cache peers.
key
-
CacheException
public Element refresh(Object key, boolean quiet) 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.
If the element is absent it is created
Quiet methods are used if argument 1 is true, so that statistics are not affected,
but note that replication will then not occur
key
- quiet
- whether the backing cache is quietly updated or not,
if true replication will not occur
CacheException
protected void refreshElement(Element element, Ehcache backingCache) throws Exception
element
- the Element to refreshbackingCache
- the underlying Ehcache
.
Exception
protected Element refreshElement(Element element, Ehcache backingCache, boolean quiet) throws Exception
element
- the Element to refreshbackingCache
- the underlying Ehcache
.quiet
- whether to use putQuiet or not, if true replication will not occur
Exception
protected static Element makeAndCheckElement(Object key, Object value) throws CacheException
key
- value
-
CacheException
- for various illegal states which could be harmful
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |