| java.lang.Object com.quadcap.util.collections.Cache
All known Subclasses: com.quadcap.http.servlets.file.FileCache,
Cache | abstract public class Cache (Code) | | This class manages a number of buffers on an underlying store.
What about write-through policies?
author: Stan Bailes |
checkCache | void checkCache()(Code) | | |
flush | public void flush() throws IOException(Code) | | Flush all modified items back to the underlying store.
|
get | public Object get(Object key) throws IOException(Code) | | Get the specified object from the cache, if available; from the
underlying store if not. In any case, the object (if found)
should be in the cache after this call.
If the object isn't in the cache OR the underlying store,
this method should return null, and the contents of both the cache
and the underlying store should remain unchanged.
This implementation doesn't change the underlying store, but
the cache ends up holding a CacheItem with a null data component.
Parameters: key - the search key return the data associated with the key |
getCacheable | public Cacheable getCacheable(Object key) throws IOException(Code) | | Search the cache for the specified key and return the associated
cache item if one was found. Otherwise, find a free cache item
and initialize it from the underlying store.
Parameters: key - the search key the cache item associated with the specified key. |
getCacheable | Cacheable getCacheable() throws IOException(Code) | | Find a free cache slot. If necessary, seize an existing cache
slot, with preference for the "least recently used" item.
This function should only be called if the lock on the cache is
held by this thread.
|
init | public void init(Object store, int size)(Code) | | Initialize the cache.
Parameters: s - the underlying store Parameters: size - the size of the cache |
makeCacheable | abstract public Cacheable makeCacheable()(Code) | | Factory to create an empty cache slot. Only a fixed number of
cache slots should be created, and they should then be recycled,
never destroyed.
|
put | public void put(Object key, Object val) throws IOException(Code) | | Store the object in the cache. The object will be marked dirty,
and will eventually be written back to the underlying store.
|
setLock | public void setLock(Object lock)(Code) | | Specify the lock-object to be used to synchronize access to the
cache. If the lock isn't specified, it defaults to the cache
object itself.
Parameters: lock - the lock object |
|
|