|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.croftsoft.core.util.cache.MemoryMapCache
public class MemoryMapCache
A Cache implementation that is backed by a memory Map.
The InputStreams are read and stored to the Map as byte arrays.
Cache,
WeakHashMap,
com.orbs.open.a.mpl.util.SoftHashMap| Constructor Summary | |
|---|---|
MemoryMapCache(Map map)
|
|
| Method Summary | |
|---|---|
boolean |
isAvailable(Id id)
Returns false if the content is no longer available. |
InputStream |
retrieve(Id id)
Retrieves the content associated with this Id. |
Id |
store(InputStream in)
Stores the contents and returns an Id to be used for retrieval. |
Id |
validate(Id id,
ContentAccessor contentAccessor)
"Validates" the content by confirming that identical content already exists in the cache; or, if otherwise necessary, storing a new copy of the content in the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MemoryMapCache(Map map)
| Method Detail |
|---|
public Id validate(Id id,
ContentAccessor contentAccessor)
throws IOException
Cache
validate in interface Cacheid - The content identifier passed to isAvailable() to determine if
the content is already valid. The parameter may be any Id
object that potentially matches via the equals() method.contentAccessor - An object capable of making content accessible via an InputStream.
For example, a ContentAccessor might retrieve content from a
website via a URL, a database or file storage, a remote object
such as another cache, or even dynamically generate the content
upon demand. As yet another possibility, a ContentAccessor object
may potentially attempt to access the content from several
different sources sequentially until it is successful.
If valid content was already available in the cache, the returned Id object will be the id parameter.
If valid content was not already available and the content could not be accessed and stored via the contentAccessor, the returned value will be null.
If valid content was not already available and the content could be accessed and stored via the contentAccessor, the returned value will be a new Id object with values that may or may not equal that of the id object parameter, depending on the actual content available via the contentAccessor.
IOException
public Id store(InputStream in)
throws IOException
CacheReads the stream until completion and closes it before return.
store in interface CacheIOException
public InputStream retrieve(Id id)
throws IOException
Cache
retrieve in interface Cacheid - Returns the content associated with this id or its equivalent.
IOExceptionpublic boolean isAvailable(Id id)
Cache
isAvailable in interface Cacheid - An Id object to be used to retrieve the content.
|
CroftSoft Javadoc | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||