|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.util.CacheMap<Object,Object>
org.zkoss.util.resource.ResourceCache<K,V>
public class ResourceCache<K,V>
Used to cache resources.
To use this class, you have to implement Loader and then
ResourceCache will use it to check whether a resource is gone,
modified and load the resource.
Unlike CacheMap, it is thread-safe.
The default check period depends on the library property called org.zkoss.util.resource.checkPeriod (unit: second). If not specified, 5 seconds are assumed
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.zkoss.util.CacheMap |
|---|
CacheMap.Value<V> |
| Field Summary | |
|---|---|
protected Loader<K,V> |
_loader
The loader. |
| Fields inherited from class org.zkoss.util.CacheMap |
|---|
EXPUNGE_CONTINUE, EXPUNGE_NO, EXPUNGE_STOP, EXPUNGE_YES |
| Fields inherited from interface org.zkoss.util.Cache |
|---|
DEFAULT_LIFETIME, DEFAULT_MAX_SIZE |
| Constructor Summary | |
|---|---|
ResourceCache(Loader<K,V> loader)
Constructor. |
|
ResourceCache(Loader<K,V> loader,
int initsz)
Constructor. |
|
| Method Summary | |
|---|---|
void |
clear()
It is OK to clear up all cached resources if you don't want to cache it. |
V |
get(Object src)
Returns the resource, or null if not found. |
int |
getCheckPeriod()
Returns how often to check (unit=milliseconds). |
Loader<K,V> |
getLoader()
Returns the loader. |
Object |
put(Object src,
Object val)
Don't use it. |
Object |
remove(Object src)
It is OK to remove the resource if you don't want to cache it. |
ResourceCache |
setCheckPeriod(int checkPeriod)
Sets how often to check (unit=milliseconds). |
| Methods inherited from class org.zkoss.util.CacheMap |
|---|
canExpunge, clone, containsKey, containsKeyWithoutExpunge, containsValue, entrySet, equals, expunge, getLifetime, getMaxSize, getWithoutExpunge, hashCode, isEmpty, isEmptyWithoutExpunge, keySet, onExpunge, putAll, setLifetime, setMaxSize, shallExpunge, size, sizeWithoutExpunge, toString, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Loader<K,V> _loader
| Constructor Detail |
|---|
public ResourceCache(Loader<K,V> loader)
loader - the loader to load resource
public ResourceCache(Loader<K,V> loader,
int initsz)
loader - the loader to load resourceinitsz - the initial size of the map| Method Detail |
|---|
public Loader<K,V> getLoader()
public int getCheckPeriod()
Default: 5000
public ResourceCache setCheckPeriod(int checkPeriod)
public V get(Object src)
get in interface Map<Object,Object>get in interface Cache<Object,Object>get in class CacheMap<Object,Object>
public Object put(Object src,
Object val)
put in interface Map<Object,Object>put in interface Cache<Object,Object>put in class CacheMap<Object,Object>UnsupportedOperationException - if calledpublic Object remove(Object src)
remove in interface Map<Object,Object>remove in interface Cache<Object,Object>remove in class CacheMap<Object,Object>public void clear()
clear in interface Map<Object,Object>clear in interface Cache<Object,Object>clear in class CacheMap<Object,Object>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||