| org.zkoss.util.Cache
All known Subclasses: org.zkoss.util.ThreadLocalCache, org.zkoss.util.MultiCache, org.zkoss.util.CacheMap,
Cache | public interface Cache (Code) | | Represents a cache.
The interface is similar to java.util.Map but simpler to implement.
author: tomyeh since: 3.0.0 |
Field Summary | |
final public static int | DEFAULT_LIFETIME The default minimal lifetime, unit=milliseconds. | final public static int | DEFAULT_MAX_SIZE The default maximal allowed size. |
Method Summary | |
public void | clear() Clears all objects being cached. | public boolean | containsKey(Object key) Returns whether the specified key is stored. | public Object | get(Object key) Returns the object of the specified key, or null if not found. | public int | getLifetime() Returns the minimal lifetime, unit=milliseconds. | public int | getMaxSize() Returns the maximal allowed size. | public Object | put(Object key, Object value) Stores an object to the cache. | public Object | remove(Object key) Removes an object from the cache. | public void | setLifetime(int lifetime) Sets the minimal lifetime. | public void | setMaxSize(int maxsize) Sets the maximal allowed size. |
DEFAULT_LIFETIME | final public static int DEFAULT_LIFETIME(Code) | | The default minimal lifetime, unit=milliseconds. It is 30 minutes.
|
DEFAULT_MAX_SIZE | final public static int DEFAULT_MAX_SIZE(Code) | | The default maximal allowed size. It is 512.
|
clear | public void clear()(Code) | | Clears all objects being cached.
|
containsKey | public boolean containsKey(Object key)(Code) | | Returns whether the specified key is stored.
|
get | public Object get(Object key)(Code) | | Returns the object of the specified key, or null if not found.
|
getLifetime | public int getLifetime()(Code) | | Returns the minimal lifetime, unit=milliseconds.
An mapping won't be removed by GC unless the minimal lifetime
or the maximal allowed size exceeds.
See Also: Cache.getMaxSize |
getMaxSize | public int getMaxSize()(Code) | | Returns the maximal allowed size. Defalut:
Cache.DEFAULT_MAX_SIZE .
An mapping won't be removed by GC unless the minimal lifetime
or the maximal allowed size exceeds.
See Also: Cache.getLifetime |
put | public Object put(Object key, Object value)(Code) | | Stores an object to the cache.
the previous value of the same, or null if no such value |
remove | public Object remove(Object key)(Code) | | Removes an object from the cache.
the object if found. |
setLifetime | public void setLifetime(int lifetime)(Code) | | Sets the minimal lifetime. Default:
Cache.DEFAULT_LIFETIME .
Parameters: lifetime - the lifetime, unit=milliseconds;if non-posive, they will be removed immediately. See Also: Cache.getLifetime |
|
|