|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Cache
Stores the content and then returns an Id which may be used to read the content later, if still available.
SoftCache
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. |
Method Detail |
---|
Id validate(Id id, ContentAccessor contentAccessor) throws IOException
id
- 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
Id store(InputStream in) throws IOException
Reads the stream until completion and closes it before return.
IOException
InputStream retrieve(Id id) throws IOException
id
- Returns the content associated with this id or its equivalent.
IOException
boolean isAvailable(Id id)
id
- 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 |