Package com.skava.accounts.service.impl
Class CacheImpl<T>
java.lang.Object
com.skava.accounts.service.impl.CacheImpl<T>
- Type Parameters:
T
- the class
This class has all the cache related functionalities like save to cache, delete from cache
and get cache.
- Author:
- Infosys Equinox
-
Constructor Summary
ConstructorsConstructorDescriptionCacheImpl
(com.fasterxml.jackson.databind.ObjectMapper objectMapper, AccountCommonServices commonservices) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearCache
(Set<String> cacheNames) clearCache - Clears the cache for all the cacheNames present.<P> Object
covertObj
(P value) This method is used to convert the given value to object.deleteCache
(String cacheName) deleteCache - Used to delete the cache corresponding to the given cacheName.deleteCacheWithKey
(String cacheName, String cacheKey) deleteCacheWithKey - Used to delete the cache corresponding to the given cacheKey and cacheName.org.springframework.cache.Cache
getCache.getValueFromCache
(String cacheName, String key) Gets the Object value from cache according to the given cache name and key.saveDetailsToCache
(String cacheName, String cacheKey, T entity) saveDetailsToCache - Used to save details in cache.
-
Constructor Details
-
CacheImpl
@Autowired public CacheImpl(com.fasterxml.jackson.databind.ObjectMapper objectMapper, AccountCommonServices commonservices)
-
-
Method Details
-
getCache
getCache.
-
covertObj
This method is used to convert the given value to object. Removed: return objectMapper.convertValue(value, value.getClass()); Based on object type in previous versions, same object is returned. Returning rawType from jackson-databind is removed in newer versions. Hence the conversion is not needed in latest version.- Parameters:
value
- Holds value for converting value to object.- Returns:
Object value.
-
saveDetailsToCache
saveDetailsToCache - Used to save details in cache.- Parameters:
cacheName
- aString
object.cacheKey
- aString
object.entity
- aSerializable
object.- Returns:
- a
Object
object.
-
deleteCacheWithKey
deleteCacheWithKey - Used to delete the cache corresponding to the given cacheKey and cacheName.- Parameters:
cacheName
- The name of the cache that is to be deleted.cacheKey
- The key of the cache that is to be deleted.- Returns:
- a
Object
object.
-
deleteCache
deleteCache - Used to delete the cache corresponding to the given cacheName.- Parameters:
cacheName
- The name of the cache that is to be deleted.- Returns:
- a
Object
object.
-
clearCache
clearCache - Clears the cache for all the cacheNames present.- Parameters:
cacheNames
- list of cacheNames which is to be cleared.
-
getValueFromCache
Gets the Object value from cache according to the given cache name and key.- Parameters:
cacheName
- The name of the cache that is to be deleted.key
- The key of the cache that is to be deleted.- Returns:
- a
Object
object
-