Package com.kheops.util
Class KMemoryDataCache
java.lang.Object
com.kheops.util.KAbstractDataCache
com.kheops.util.KMemoryDataCache
- All Implemented Interfaces:
KSchedulerClient
A class used to store and retrieve data stored on memory.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
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 -
Field Summary
Fields inherited from class com.kheops.util.KAbstractDataCache
currentSize, hits, maximumSize, misses
-
Constructor Summary
ConstructorDescriptionKMemoryDataCache
(long maximumSize) Constructs a KMemoryDataCache with the specified maximum size -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the table contains the data with the specified keysvoid
export
(KAbstractDataCache cache) long
getCount()
long
long
Gets the memory cache current sizelong
getCurrentSize
(String partialKey) long
Gets the memory cache maximum allowed sizevoid
Removes the memory cache with the specified keyvoid
void
removeMatching
(String partialKey) byte[]
Retrieves the data previously stored using the specified key.void
schCallback
(int jobId) This method is called by the KScheduler to remove the expired datavoid
void
Stores the specified data in memory cache using the specified key.Methods inherited from class com.kheops.util.KAbstractDataCache
getHits, getMisses, getMonitoringInfo, getMonitoringInfo
-
Constructor Details
-
KMemoryDataCache
public KMemoryDataCache(long maximumSize) Constructs a KMemoryDataCache with the specified maximum size- Parameters:
maximumSize
- the maximum size of memory data cache allowed
-
-
Method Details
-
store
- Specified by:
store
in classKAbstractDataCache
-
store
Stores the specified data in memory cache using the specified key. The specified time to live (in ms) is the data expiration time. After this time is expired, the data will be removed from the cache. If timeToLive is CacheConstants.CACHE_TIMEOUT_NEVER_EXPIRE, expiration will be disabled for this data (it will stay in cache until explicitly removed using the remove(String key) method.- Parameters:
key
- the key of the KMemoryDataCache where to store the datadata
- the data to be storedtimeTolive
- amount of time before the data expires
-
retrieve
Retrieves the data previously stored using the specified key. If the data does not exist, no exception is thrown but the method returns null.- Parameters:
key
- unique identifier used to search for the corresponding data- Returns:
- data the data retrieved from memory
this method keeps the count of sucessfull and unsecessfull data retrieval
-
contains
Checks if the table contains the data with the specified keys- Parameters:
key
- the corresponding key- Returns:
- the boolean value of the result
-
getCurrentSize
public long getCurrentSize()Gets the memory cache current size- Overrides:
getCurrentSize
in classKAbstractDataCache
- Returns:
- the current cache size
-
getMaximumSize
public long getMaximumSize()Gets the memory cache maximum allowed size- Overrides:
getMaximumSize
in classKAbstractDataCache
- Returns:
- the maximum cache size
-
remove
Removes the memory cache with the specified key- Parameters:
key
- the key of the data to be removed
-
schCallback
public void schCallback(int jobId) This method is called by the KScheduler to remove the expired data- Specified by:
schCallback
in interfaceKSchedulerClient
- Parameters:
jobId
- the corresponding job Id
-
removeAll
public void removeAll()- Specified by:
removeAll
in classKAbstractDataCache
-
removeMatching
- Specified by:
removeMatching
in classKAbstractDataCache
-
export
- Specified by:
export
in classKAbstractDataCache
- Throws:
IOException
-
getCount
public long getCount()- Specified by:
getCount
in classKAbstractDataCache
-
getCount
- Specified by:
getCount
in classKAbstractDataCache
-
getCurrentSize
- Specified by:
getCurrentSize
in classKAbstractDataCache
-