public final class Cache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.io.File |
cachePath |
private static java.lang.String |
FILE_DB_NAME |
private static Compressor |
fileDB |
private static ArrayStack |
fileDBunbuffered |
static ConcurrentLog |
log |
private static long |
maxCacheSize |
private static java.lang.String |
prefix |
private static java.lang.String |
RESPONSE_HEADER_DB_NAME |
private static MapHeap |
responseHeaderDB |
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
static void |
clear()
clear the cache
|
static void |
close()
close the databases
|
static void |
commit() |
static void |
delete(byte[] hash)
removed response header and cached content from the database
|
static long |
getActualCacheDocCount()
get the current actual cache size
|
static long |
getActualCacheSize()
get the current actual cache size
|
static byte[] |
getContent(byte[] hash)
Returns the content of a cached resource as byte[]
|
static ResponseHeader |
getResponseHeader(byte[] hash)
Returns an object containing metadata about a cached resource
|
static boolean |
has(byte[] urlhash)
check if the responseHeaderDB and the fileDB has an entry for the given url
|
static boolean |
hasContent(byte[] hash) |
static void |
init(java.io.File htCachePath,
java.lang.String peerSalt,
long CacheSizeMax) |
static void |
setMaxCacheSize(long newCacheSize)
This method changes the HTCache size.
|
static void |
store(DigestURL url,
ResponseHeader responseHeader,
byte[] file) |
private static final java.lang.String RESPONSE_HEADER_DB_NAME
private static final java.lang.String FILE_DB_NAME
private static MapHeap responseHeaderDB
private static Compressor fileDB
private static ArrayStack fileDBunbuffered
private static long maxCacheSize
private static java.io.File cachePath
private static java.lang.String prefix
public static final ConcurrentLog log
public static void init(java.io.File htCachePath, java.lang.String peerSalt, long CacheSizeMax)
public static void commit()
public static void clear()
public static void setMaxCacheSize(long newCacheSize)
the
- new cache size in bytespublic static long getActualCacheSize()
public static long getActualCacheDocCount()
public static void close()
public static void store(DigestURL url, ResponseHeader responseHeader, byte[] file) throws java.io.IOException
java.io.IOException
public static boolean has(byte[] urlhash)
url
- the url of the resourcepublic static ResponseHeader getResponseHeader(byte[] hash)
url
- the URL
of the resourceinfo object
IllegalAccessException
- if the SecurityManager
doesn't allow instantiation
of the info object with the given protocolUnsupportedProtocolException
- if the protocol is not supported and therefore the
info object couldn't be createdpublic static byte[] getContent(byte[] hash)
url
- the requested resourcenull
is returned.public static boolean hasContent(byte[] hash)
public static void delete(byte[] hash) throws java.io.IOException
url
- java.io.IOException