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
Nested ClassesModifier and TypeClassDescriptionprotected classThis 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
ConstructorsConstructorDescriptionKMemoryDataCache(long maximumSize) Constructs a KMemoryDataCache with the specified maximum size -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the table contains the data with the specified keysvoidexport(KAbstractDataCache cache) longgetCount()longlongGets the memory cache current sizelonggetCurrentSize(String partialKey) longGets the memory cache maximum allowed sizevoidRemoves the memory cache with the specified keyvoidvoidremoveMatching(String partialKey) byte[]Retrieves the data previously stored using the specified key.voidschCallback(int jobId) This method is called by the KScheduler to remove the expired datavoidvoidStores 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:
storein 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:
getCurrentSizein classKAbstractDataCache- Returns:
- the current cache size
-
getMaximumSize
public long getMaximumSize()Gets the memory cache maximum allowed size- Overrides:
getMaximumSizein 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:
schCallbackin interfaceKSchedulerClient- Parameters:
jobId- the corresponding job Id
-
removeAll
public void removeAll()- Specified by:
removeAllin classKAbstractDataCache
-
removeMatching
- Specified by:
removeMatchingin classKAbstractDataCache
-
export
- Specified by:
exportin classKAbstractDataCache- Throws:
IOException
-
getCount
public long getCount()- Specified by:
getCountin classKAbstractDataCache
-
getCount
- Specified by:
getCountin classKAbstractDataCache
-
getCurrentSize
- Specified by:
getCurrentSizein classKAbstractDataCache
-