Package com.kheops.util
Class KObjectCache
java.lang.Object
com.kheops.util.KObjectCache
A class used to store and retrieve data stored on memory.
-
Constructor Summary
ConstructorDescriptionKObjectCache
(int maximumSize) Constructs a KMemoryDataCache with the specified maximum size -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the table contains the data with the specified keyslong
Gets the memory cache current sizedouble
This method returns the sucessfull retrieval data count over the number of retrieval attemps It enables to get statistic of the retrieve methodlong
Gets the memory cache maximum allowed sizevoid
Removes the memory cache with the specified keyRetrieves the data previously stored using the specified key.void
Stores the specified object in memory cache using the specified key.
-
Constructor Details
-
KObjectCache
public KObjectCache(int maximumSize) Constructs a KMemoryDataCache with the specified maximum size- Parameters:
maximumSize
- the maximum number of objects the cache can contain
-
-
Method Details
-
store
Stores the specified object in memory cache using the specified key.- Parameters:
key
- the key of the KMemoryDataCache where to store the dataobject
- the object to be stored
-
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- Returns:
- the current cache size
-
getMaximumSize
public long getMaximumSize()Gets the memory cache maximum allowed size- Returns:
- the maximum cache size
-
remove
Removes the memory cache with the specified key- Parameters:
key
- the key of the data to be removed
-
getEfficiency
public double getEfficiency()This method returns the sucessfull retrieval data count over the number of retrieval attemps It enables to get statistic of the retrieve method- Returns:
- the effeciency ratio
-