| java.lang.Object org.openlaszlo.cache.Cache
All known Subclasses: org.openlaszlo.cm.CompilationManager, org.openlaszlo.cache.RequestCache, org.openlaszlo.cache.PersistentMap, org.openlaszlo.compiler.CompilerMediaCache, org.openlaszlo.sc.ScriptCompiler,
Cache | abstract public class Cache (Code) | | A base class for maintaining a disk-backed cache of requests.
Cache has 2 sequenced hash map of Items. Each item uniquely
represents something to be cached (and transcoded). The
first map contains items that are "in memory". Items that
are "in memory" are also stored on disk. The second map
contains items that are only on disk.
The cache chucks out (via LRU) items from each map when it is beyond
its maximum size for that map. Each time an item is requested,
it is moved to the front of the "in-memory" map.
Each item has its own lock. When an item is requested,
we lock it and then go to the DataSource to see if
we need to refresh any copy of it we have.
When an item has it's size change or it marked dirty, it
is also marked as needing its size changed reckoned with the
cache sizes. Whenever the cache is locked and runs into
an item that needs reckoning, it updates the cache sizes
to reflect the item.
The cache supports multiple encodings of individual items.
author: Eric Bloch |
Method Summary | |
protected void | afterCacheRead(Object metaData) this routine is a place holder which can be overridden to hook into
the cache loading. | public synchronized boolean | clearCache() | public synchronized void | dumpXML(StringBuffer buf, String name, boolean details) | protected synchronized Item | findItem(Serializable key, String enc, boolean doLockAndLeaveActive) Find and optionally lock item in the cache that matches this key
If the item doesn't exist, create it. | public synchronized long | getDiskSize() | protected synchronized Item | getItem(Serializable key) | public synchronized long | getMaxDiskSize() | public synchronized long | getMaxMemSize() | public synchronized long | getMemSize() | public synchronized void | setMaxDiskSize(long size) Set the maximum size of the on-disk cache. | public synchronized void | setMaxMemSize(long size) Set the maxmimum size of the in-memory cache. | protected synchronized void | updateCache(Item item) Reckon this item and update the cache. | protected synchronized void | updateCacheAndDeactivateItem(Item item) Reckon and deactivate this item and update the cache. | public synchronized void | updateMapsAndReckonItems(boolean clearAll) Update the maps and remove items that
push us beyond the maximum size of the
cache. |
DEFAULT_MEM_ITEM_MAX | final public String DEFAULT_MEM_ITEM_MAX(Code) | | |
Cache | public Cache(String name, File cacheDirectory, Properties props) throws IOException(Code) | | Creates a new Cache instance.
Parameters: name - Parameters: cacheDirectory - a File naming a directorywhere cache files should be kept Parameters: props - |
afterCacheRead | protected void afterCacheRead(Object metaData)(Code) | | this routine is a place holder which can be overridden to hook into
the cache loading. It is used by the cm/CompilationManager to get
at the contents of the dependencyTracker as it is being loaded from
disk and modify various paths that might have changed since
prefetching.
|
clearCache | public synchronized boolean clearCache()(Code) | | Clear the cache
|
dumpXML | public synchronized void dumpXML(StringBuffer buf, String name, boolean details)(Code) | | Dump textual XML representation of cache to buf
Parameters: buf - buffer to append Parameters: name - name for XML element Parameters: details - if true, dump details |
findItem | protected synchronized Item findItem(Serializable key, String enc, boolean doLockAndLeaveActive) throws IOException(Code) | | Find and optionally lock item in the cache that matches this key
If the item doesn't exist, create it. If the item
does exist, move it to the top of the LRU list by removing
and re-adding.
the locked item |
getDiskSize | public synchronized long getDiskSize()(Code) | | Get the current size of the on-disk cache
|
getItem | protected synchronized Item getItem(Serializable key)(Code) | | an item if it exists or null otherwise |
getMaxDiskSize | public synchronized long getMaxDiskSize()(Code) | | Get the maximum size of the on-disk cache cache
|
getMaxMemSize | public synchronized long getMaxMemSize()(Code) | | Get the maxmimum size of the in-memory cache
|
getMemSize | public synchronized long getMemSize()(Code) | | Get the current size of the in-memory cache
|
setMaxDiskSize | public synchronized void setMaxDiskSize(long size)(Code) | | Set the maximum size of the on-disk cache.
Can cause the cache to remove things.
|
setMaxMemSize | public synchronized void setMaxMemSize(long size)(Code) | | Set the maxmimum size of the in-memory cache.
Can cause the cache to remove things.
|
updateCache | protected synchronized void updateCache(Item item)(Code) | | Reckon this item and update the cache.
|
updateCacheAndDeactivateItem | protected synchronized void updateCacheAndDeactivateItem(Item item)(Code) | | Reckon and deactivate this item and update the cache.
|
updateMapsAndReckonItems | public synchronized void updateMapsAndReckonItems(boolean clearAll)(Code) | | Update the maps and remove items that
push us beyond the maximum size of the
cache. Never empty out the maps.
Always leave at least one item if clearAll is false.
Also ignore items that are in progress.
Parameters: clearAll - if false, must leave one elt in each map |
|
|