Package com.jk.core.cache.simple
Class JKAbstractCacheManager
java.lang.Object
com.jk.core.cache.simple.JKAbstractCacheManager
- All Implemented Interfaces:
JKCacheManager
- Direct Known Subclasses:
JKDefaultCacheManager
,JKTimedAndSizeCacheManager
This abstract class provides a base implementation for cache management.
This class implements the JKCacheManager
interface.
- Version:
- 1
- Author:
- Dr. Jalal H. Kiswani
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasMap()
This method transformJKCacheManager
into a map.void
This method caches data with the specified key inside theJKCacheManager
object instance.<T> void
This method caches data with the associated key inside the specified cached data container.void
clear()
This method clears all the data cached inside theJKCacheManager
.void
This method clears the data cached inside the specified data type.This method creates a new cache map for theJKAbstractCacheManager
.<T> T
This method gets the cached data associated with the specified key, and stored in the specified data container type.<T> List<T>
This method gets the cached data container that is associated with the specified key as a list.getCachableMap
(Class<?> clas) This method gets the cached data container as a map.This method returns a set of all the currently cached classes.boolean
This method checks whether thisJKAbstractCacheManager
allow null values or not.boolean
isAvailable
(Object key, Class<?> clas) This method checks whether the specified cached data is available or not.void
This method removes the cached data fromJKCacheManager
.void
This method removes the cached data associated with the specified key fromJKCacheManager
.void
setAllowNullable
(boolean allowNullable) This method changes the value which specify whether thisJKAbstractCacheManager
allows null value or not.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
-
Field Details
-
logger
Represents this class logger.
-
-
Constructor Details
-
JKAbstractCacheManager
public JKAbstractCacheManager()
-
-
Method Details
-
cache
This method caches data with the specified key inside theJKCacheManager
object instance.- Specified by:
cache
in interfaceJKCacheManager
- Parameters:
key
- Specifies the key of the cached data.object
- Specifies the cached data.
-
cache
This method caches data with the associated key inside the specified cached data container.- Specified by:
cache
in interfaceJKCacheManager
- Type Parameters:
T
- Specifies the generic type of the cached data.- Parameters:
key
- Specifies the key of the cached data.object
- Specifies the object to be cached.clas
- Specifies the cached data container type.
-
clear
This method clears the data cached inside the specified data type.- Specified by:
clear
in interfaceJKCacheManager
- Parameters:
clas
- Specifies the data type to be cleared.
-
get
This method gets the cached data container that is associated with the specified key as a list.- Specified by:
get
in interfaceJKCacheManager
- Type Parameters:
T
- Specifies the generic type of the cached data.- Parameters:
key
- Specifies the key associated with the cached data.- Returns:
- a list of the cached data container content.
-
get
This method gets the cached data associated with the specified key, and stored in the specified data container type.- Specified by:
get
in interfaceJKCacheManager
- Type Parameters:
T
- Specifies the generic type of the cached data.- Parameters:
key
- Specifies the key associated with the cached data.clas
- Specifies the cached data container type.- Returns:
- the cached data, returns null if there's no entry, or if the specified data type has been cleared.
-
getCachableMap
This method gets the cached data container as a map.- Specified by:
getCachableMap
in interfaceJKCacheManager
- Parameters:
clas
- Specifies the cached data container type.- Returns:
- a map with the specified cached data.
-
createCacheMap
This method creates a new cache map for theJKAbstractCacheManager
.- Returns:
- the new cache map.
-
isAllowNullable
public boolean isAllowNullable()This method checks whether thisJKAbstractCacheManager
allow null values or not.- Returns:
- true, if it allows null values, false, otherwise.
-
isAvailable
This method checks whether the specified cached data is available or not.- Specified by:
isAvailable
in interfaceJKCacheManager
- Parameters:
key
- Specifies the id of the cached data.clas
- Specifies the cached data container type.- Returns:
- true, if is available, false otherwise.
-
remove
This method removes the cached data fromJKCacheManager
.- Specified by:
remove
in interfaceJKCacheManager
- Parameters:
key
- Specifies the key of the cached data.clas
- Specifies the cached data container type.
-
setAllowNullable
public void setAllowNullable(boolean allowNullable) This method changes the value which specify whether thisJKAbstractCacheManager
allows null value or not.- Parameters:
allowNullable
- Indicates whether null values are allowed (true) or not (false).
-
clear
public void clear()This method clears all the data cached inside theJKCacheManager
.- Specified by:
clear
in interfaceJKCacheManager
-
remove
This method removes the cached data associated with the specified key fromJKCacheManager
.- Specified by:
remove
in interfaceJKCacheManager
- Parameters:
key
- Specifies the key associated with the cached data.
-
getCacheClasses
This method returns a set of all the currently cached classes.- Specified by:
getCacheClasses
in interfaceJKCacheManager
- Returns:
- a set of all the currently cached classes.
-
toString
-
asMap
This method transformJKCacheManager
into a map.- Specified by:
asMap
in interfaceJKCacheManager
- Returns:
- a map that represents the
JKCachedManager
-