public class ResourceCache<K,V> extends CacheMap<Object,Object>
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
CacheMap.Value<V>| Modifier and Type | Field and Description |
|---|---|
protected Loader<K,V> |
_loader
The loader.
|
EXPUNGE_CONTINUE, EXPUNGE_NO, EXPUNGE_STOP, EXPUNGE_YESDEFAULT_LIFETIME, DEFAULT_MAX_SIZE| Constructor and Description |
|---|
ResourceCache(Loader<K,V> loader)
Constructor.
|
ResourceCache(Loader<K,V> loader,
int initsz)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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).
|
canExpunge, clone, containsKey, containsKeyWithoutExpunge, containsValue, entrySet, equals, expunge, getLifetime, getMaxSize, getWithoutExpunge, hashCode, isEmpty, isEmptyWithoutExpunge, keySet, onExpunge, putAll, setLifetime, setMaxSize, shallExpunge, size, sizeWithoutExpunge, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic ResourceCache(Loader<K,V> loader)
loader - the loader to load resourcepublic int getCheckPeriod()
Default: 5000
public ResourceCache setCheckPeriod(int checkPeriod)
public Object remove(Object src)
Copyright © 2018. All rights reserved.