Package com.jk.core.cache.impl
Class JKTimedAndSizeCacheManager
java.lang.Object
com.jk.core.cache.simple.JKAbstractCacheManager
com.jk.core.cache.impl.JKTimedAndSizeCacheManager
- All Implemented Interfaces:
JKCacheManager
This class provides suitable methods used for caching and retrieval of data
with specified life time while limiting the cache to certain number of
entries.
It extends the JKAbstractCacheManager class.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Field Summary
Fields inherited from class com.jk.core.cache.simple.JKAbstractCacheManager
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JKMapThis method constructs a newJKMapinstance with the defaultmaxCountandtimeInSecondsspecified usingCacheBuilderintThis methods gets the maximum number of entries the cache may contain.intThis methods returns the timeout time in which entries are automatically removed from the cache after it.static voidThis is the main method that demonstrates the usage of theJKTimedAndSizeCacheManagerclass.voidsetMaxCount(int maxCount) This method sets the maximum number of entries the cache may contain.voidsetTimeInSeconds(int timeInSeconds) This methods sets the timeout time in which entries are automatically removed from the cache after it.Methods inherited from class com.jk.core.cache.simple.JKAbstractCacheManager
asMap, cache, cache, clear, clear, get, get, getCachableMap, getCacheClasses, isAllowNullable, isAvailable, remove, remove, setAllowNullable, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.jk.core.cache.JKCacheManager
get
-
Constructor Details
-
JKTimedAndSizeCacheManager
public JKTimedAndSizeCacheManager()
-
-
Method Details
-
createCacheMap
This method constructs a newJKMapinstance with the defaultmaxCountandtimeInSecondsspecified usingCacheBuilder- Overrides:
createCacheMapin classJKAbstractCacheManager- Returns:
- the newly constructed
JKMap.
-
getTimeInSeconds
public int getTimeInSeconds()This methods returns the timeout time in which entries are automatically removed from the cache after it.- Returns:
- the timeout value in seconds.
-
setTimeInSeconds
public void setTimeInSeconds(int timeInSeconds) This methods sets the timeout time in which entries are automatically removed from the cache after it.- Parameters:
timeInSeconds- Specifies the timeout value in seconds.
-
getMaxCount
public int getMaxCount()This methods gets the maximum number of entries the cache may contain.- Returns:
- the maximum number of entries the cache may contain.
-
setMaxCount
public void setMaxCount(int maxCount) This method sets the maximum number of entries the cache may contain.- Parameters:
maxCount- Specifies the maximum number of entries the cache may contain.
-
main
This is the main method that demonstrates the usage of theJKTimedAndSizeCacheManagerclass.It sets up a cache manager, configures its maximum count and timeout, and performs cache operations.
It also showcases cache retrieval and usage.
- Parameters:
args- the command-line arguments.
-