public class KMemoryDataCache extends KAbstractDataCache implements KSchedulerClient
Modifier and Type | Class and Description |
---|---|
protected class |
KMemoryDataCache.CachedData
This inner-class encapsutale the concept of cache
It constains the data as well as the amount of time that the data
can remain in memory before it becomes expired
|
currentSize, hits, maximumSize, misses
Constructor and Description |
---|
KMemoryDataCache(long maximumSize)
Constructs a KMemoryDataCache with the specified maximum size
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.String key)
Checks if the table contains the data with the specified keys
|
void |
export(KAbstractDataCache cache) |
long |
getCount() |
long |
getCount(java.lang.String partialKey) |
long |
getCurrentSize()
Gets the memory cache current size
|
long |
getCurrentSize(java.lang.String partialKey) |
long |
getMaximumSize()
Gets the memory cache maximum allowed size
|
void |
remove(java.lang.String key)
Removes the memory cache with the specified key
|
void |
removeAll() |
void |
removeMatching(java.lang.String partialKey) |
byte[] |
retrieve(java.lang.String key)
Retrieves the data previously stored using the specified key.
|
void |
schCallback(int jobId)
This method is called by the KScheduler to remove
the expired data
|
void |
store(java.lang.String key,
byte[] data) |
void |
store(java.lang.String key,
byte[] data,
long timeTolive)
Stores the specified data in memory cache using the specified key.
|
getHits, getMisses, getMonitoringInfo, getMonitoringInfo
public KMemoryDataCache(long maximumSize)
maximumSize
- the maximum size of memory data cache allowedpublic void store(java.lang.String key, byte[] data)
store
in class KAbstractDataCache
public void store(java.lang.String key, byte[] data, long timeTolive)
key
- the key of the KMemoryDataCache where to store the datadata
- the data to be storedtimeTolive
- amount of time before the data expirespublic byte[] retrieve(java.lang.String key)
key
- unique identifier used to search for the corresponding datapublic boolean contains(java.lang.String key)
key
- the corresponding keypublic long getCurrentSize()
getCurrentSize
in class KAbstractDataCache
public long getMaximumSize()
getMaximumSize
in class KAbstractDataCache
public void remove(java.lang.String key)
key
- the key of the data to be removedpublic void schCallback(int jobId)
schCallback
in interface KSchedulerClient
jobId
- the corresponding job Idpublic void removeAll()
removeAll
in class KAbstractDataCache
public void removeMatching(java.lang.String partialKey)
removeMatching
in class KAbstractDataCache
public void export(KAbstractDataCache cache) throws java.io.IOException
export
in class KAbstractDataCache
java.io.IOException
public long getCount()
getCount
in class KAbstractDataCache
public long getCount(java.lang.String partialKey)
getCount
in class KAbstractDataCache
public long getCurrentSize(java.lang.String partialKey)
getCurrentSize
in class KAbstractDataCache