Package com.jk.core.cache
Interface JKCacheManager
- All Known Implementing Classes:
JKAbstractCacheManager
,JKDefaultCacheManager
,JKTimedAndSizeCacheManager
public interface JKCacheManager
This interface provides the necessarily methods needed for
JKCacheManager
objects.- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
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.<T> T
This method gets the cached data associated with the specified key, and stored in the specified data container type.default <T> T
get
(Object key, Class<T> clas, JKValueLoader<Object, T> loader) 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
isAvailable
(Object id, 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
.
-
Method Details
-
cache
This method caches data with the specified key inside theJKCacheManager
object instance.- Parameters:
key
- Specifies the key of the cached data.cache
- Specifies the cached data.
-
clear
This method clears the data cached inside the specified data type.- Parameters:
clas
- Specifies the data type to be cleared.
-
get
This method gets the cached data associated with the specified key, and stored in the specified data container type.- 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.
-
get
This method gets the cached data associated with the specified key, and stored in the specified data container type.In case its null, it checks the loader for the value instead, and
caches
the data if it finds it in the loader.- Type Parameters:
T
- Specifies the generic type of the cached data.- Parameters:
key
- Specified the key associated with the cached data.clas
- Specifies the cached data container type.loader
- Specifies the loader.- Returns:
- the cached data, returns null if there's no entry in the cached container no in the loader.
- See Also:
-
getCachableMap
This method gets the cached data container as a map.- Parameters:
clas
- Specifies the cached data container type.- Returns:
- a map with the specified cached data.
-
isAvailable
This method checks whether the specified cached data is available or not.- Parameters:
id
- 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
.- Parameters:
key
- Specifies the key of the cached data.clas
- Specifies the cached data container type.
-
cache
This method caches data with the associated key inside the specified cached data container.- 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
void clear()This method clears all the data cached inside theJKCacheManager
. -
remove
This method removes the cached data associated with the specified key fromJKCacheManager
.- Parameters:
key
- Specifies the key associated with the cached data.
-
getCacheClasses
This method returns a set of all the currently cached classes.- Returns:
- a set of all the currently cached classes.
-
asMap
Map asMap()This method transformJKCacheManager
into a map.- Returns:
- a map that represents the
JKCachedManager
-
get
This method gets the cached data container that is associated with the specified key as a list.- 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.
-