public class KDiskDataCache extends KAbstractDataCache
currentSize, hits, maximumSize, misses| Constructor and Description |
|---|
KDiskDataCache(java.io.File path,
long maxDiskCacheSize)
Constructs a KDiskDataCache object working with the specified directory.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(java.lang.String key,
long timeToLive)
Tests for the existance of the data identified by the specified key.
|
void |
export(KAbstractDataCache cache) |
long |
getCount() |
long |
getCount(java.lang.String partialKey)
Returns the number of items present in the cache that have file names
begining with the specified key.
|
long |
getCurrentSize(java.lang.String partialKey)
Gets the size in bytes of the data present in the cache that match the
specified key.
|
long |
getDataTime(java.lang.String key)
Gets the last time the file was modified
|
KDataCacheMonitoringInfo |
getMonitoringInfo(java.lang.String partialKey)
Returns a KDataCacheMonitoringInfo object that defines monitoring information about this data cache.
|
long |
getSize()
Gets the total size in bytes of the data present in the cache
|
java.io.File[] |
list()
Returns the list of data files present in the cache.
|
java.io.File[] |
listMatching(java.lang.String partialKey)
Get the list of data files in the cache starting with the specified string.
|
static void |
main(java.lang.String[] args)
This method is used or test purposes
|
void |
remove(java.lang.String key)
Deletes the data corresponding to the specified key.
|
void |
removeAll()
Deletes all data stored in the cache.
|
void |
removeMatching(java.lang.String partialKey)
Deletes the data files with names that begin with the specified partial
key.
|
byte[] |
retrieve(java.lang.String key,
long timeToLive)
Retrieves the data previously stored using the specified key.
|
void |
store(java.lang.String key,
byte[] data)
Stores the specified data using the specified key as the file name.
|
getCurrentSize, getHits, getMaximumSize, getMisses, getMonitoringInfopublic KDiskDataCache(java.io.File path,
long maxDiskCacheSize)
path - the base directory for storing data filesmaxDiskCacheSize - the allowed size to be used as disk cache. -1 means unlimited.public void store(java.lang.String key,
byte[] data)
throws java.io.IOException
store in class KAbstractDataCachekey - the unique file namedata - the data to store on diskjava.io.IOExceptionpublic byte[] retrieve(java.lang.String key,
long timeToLive)
throws java.io.IOException
key - unique identifier used to search for the corresponding file nametimeToLive - amount of time used to determine the data has expired.java.io.IOExceptionpublic boolean contains(java.lang.String key,
long timeToLive)
key - the unique identifier for the datatimeToLive - time used to determine if the data has expiredpublic java.io.File[] list()
public java.io.File[] listMatching(java.lang.String partialKey)
partialKey - the begining of the file name.public void remove(java.lang.String key)
key - the unique identifier for the datapublic void removeMatching(java.lang.String partialKey)
removeMatching in class KAbstractDataCachepartialKey - the partial key to matchpublic long getDataTime(java.lang.String key)
key - the file namepublic long getSize()
public void removeAll()
removeAll in class KAbstractDataCacheKDiskDataCachepublic void export(KAbstractDataCache cache) throws java.io.IOException
export in class KAbstractDataCachejava.io.IOExceptionpublic long getCount()
getCount in class KAbstractDataCachepublic long getCount(java.lang.String partialKey)
getCount in class KAbstractDataCachepartialKey - The file name to matchpublic long getCurrentSize(java.lang.String partialKey)
getCurrentSize in class KAbstractDataCachepublic KDataCacheMonitoringInfo getMonitoringInfo(java.lang.String partialKey)
KAbstractDataCachegetMonitoringInfo in class KAbstractDataCachepublic static void main(java.lang.String[] args)