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 JKMap
This method constructs a newJKMap
instance with the defaultmaxCount
andtimeInSeconds
specified usingCacheBuilder
int
This methods gets the maximum number of entries the cache may contain.int
This methods returns the timeout time in which entries are automatically removed from the cache after it.static void
This is the main method that demonstrates the usage of theJKTimedAndSizeCacheManager
class.void
setMaxCount
(int maxCount) This method sets the maximum number of entries the cache may contain.void
setTimeInSeconds
(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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.jk.core.cache.JKCacheManager
get
-
Constructor Details
-
JKTimedAndSizeCacheManager
public JKTimedAndSizeCacheManager()
-
-
Method Details
-
createCacheMap
This method constructs a newJKMap
instance with the defaultmaxCount
andtimeInSeconds
specified usingCacheBuilder
- Overrides:
createCacheMap
in 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 theJKTimedAndSizeCacheManager
class.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.
-