multivalent
Class Cache
public
class
Cache
extends Object
Cache ("a secure place of storage") holds not just set of recently seen pages,
but important information such as Preferences and perhaps sole copy of automatically saved annotations.
Types of caches:
- General - for run-of-the-mill pages, purged LRU
- Archive - for more or less regenerable information with guaranteed availability, such as annotated web pages.
Also, associated information: HTTP headers, cookies, .xdc, hygiene-type, RCS?
- User - for irreplacable information, such as Preferences, bookmarks, annotations, customized hubs,
page visitation log, patterns determining whether site/page/subtree in General or Archive
Later: check modification time of cached vs. original.
If would go into general cache and didn't take long to fetch, maybe not cache at all.
Version: $Revision: 1.10 $ $Date: 2003/06/02 05:00:11 $
See Also: DocInfo
Method Summary |
void | addArchivePattern(String pattern) |
void | changeStatus(URI uri, String related, int fromtype, int totype) |
void | delete(URI uri, String related, int type) |
void | flushAll() |
void | flushCache(int type) |
String | getGenre(String contenttype, String filename, InputStream is) |
InputStream | getInputStream(URI uri)
Return InputStream that stores in cache, perhaps decompressing,
retrieving from network if not in cache. |
InputStream | getInputStream(DocInfo di, String related, int type)
First normalizes URI.
|
File | getOutputFile(URI uri, String related, int type, Map<String,String> headers)
Return OutputStream that stores in cache, perhaps compressing.
|
OutputStream | getOutputStream(URI uri, String related, int type, Map<String,String> headers) |
boolean | isCached() |
boolean | isSeen(URI uri)
This ties whether seen page to whether it's in the cache, which can be wrong after cache is flushed. |
boolean | isSeen(String suri) |
File | mapTo(URI uri, String related, int type)
Maps
http://www.cs.berkeley.edu/~phelps/tcltk/index.html
to
basedir/edu/berkeley/cs/www/~phelps/tcltk/index.html/index.html |
void | put(URI uri, String related, int type, byte[] data)
Can't overload return types to have a get retrun String too so caller should use
String constructor with return value. |
void | put(URI uri, String related, int type, String data, Map<String,String> headers) |
void | setSeen(String suri) |
void | setSeen(String suri, boolean seen) |
public static final int ARCHIVE
public static final int CACHEONLY
public static final int COMPUTE
public static final int DONTCACHE
public static final int GENERAL
public static final Pattern HTTP_OLD_STATUS
public static final int USER
public Cache(String userdir, String tmpdir,
CHashMap<String> genremap)
public void addArchivePattern(String pattern)
public void changeStatus(URI uri, String related, int fromtype, int totype)
public void delete(URI uri, String related, int type)
public void flushAll()
public void flushCache(int type)
public String getGenre(String contenttype, String filename, InputStream is)
public InputStream getInputStream(URI uri)
Return InputStream that stores in cache, perhaps decompressing,
retrieving from network if not in cache. The InputStream is buffered.
Compressed files of type gzip (indicated by suffix .gz, .Z, or .z) are automatically
uncompressed in stream and the suffix is stripped from the returned, normalized URL.
Client does Reader, Pushback as needed.
Parameters: type Type of cache
Throws: IOException (404, ...) FileNotFoundException
public InputStream getInputStream(
DocInfo di, String related, int type)
First normalizes URI.
Client probably wants to wrap returned InputStream in a BufferedInputStream.
May mutate
uri if redirects or lexical signature; original/requested URI available in
uriin.
public File getOutputFile(URI uri, String related, int type, Map<String,String> headers)
Return OutputStream that stores in cache, perhaps compressing.
(Data automatically added to cache when getInputStream.)
Parameters: type Type of cache
public OutputStream getOutputStream(URI uri, String related, int type, Map<String,String> headers)
public boolean isCached()
public boolean isSeen(URI uri)
This ties whether seen page to whether it's in the cache, which can be wrong after cache is flushed.
public boolean isSeen(String suri)
public File mapTo(URI uri, String related, int type)
Maps
http://www.cs.berkeley.edu/~phelps/tcltk/index.html
to
basedir/edu/berkeley/cs/www/~phelps/tcltk/index.html/index.htmlParameters: uri URI of base document (if null, use URI of cache) related Name of related file, such as "headers.txt" (if null, file is base document)
public void put(URI uri, String related, int type, byte[] data)
Can't overload return types to have a get retrun String too so caller should use
String constructor with return value.
public void put(URI uri, String related, int type, String data, Map<String,String> headers)
public void setSeen(String suri)
public void setSeen(String suri, boolean seen)