Class CacheImpl<T>

java.lang.Object
com.skava.accounts.service.impl.CacheImpl<T>
Type Parameters:
T - the class

@Service public class CacheImpl<T> extends Object
This class has all the cache related functionalities like save to cache, delete from cache and get cache.
Author:
Infosys Equinox
  • Constructor Details

    • CacheImpl

      @Autowired public CacheImpl(com.fasterxml.jackson.databind.ObjectMapper objectMapper, AccountCommonServices commonservices)
  • Method Details

    • getCache

      public org.springframework.cache.Cache getCache(String cacheName)

      getCache.

      Parameters:
      cacheName - a String object.
      Returns:
      a Object object.
    • covertObj

      public <P> Object covertObj(P value)
      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

      public Object saveDetailsToCache(String cacheName, String cacheKey, T entity)
      saveDetailsToCache - Used to save details in cache.
      Parameters:
      cacheName - a String object.
      cacheKey - a String object.
      entity - a Serializable object.
      Returns:
      a Object object.
    • deleteCacheWithKey

      public Object deleteCacheWithKey(String cacheName, String cacheKey)
      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

      public Object deleteCache(String cacheName)
      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

      public void clearCache(Set<String> cacheNames)
      clearCache - Clears the cache for all the cacheNames present.
      Parameters:
      cacheNames - list of cacheNames which is to be cleared.
    • getValueFromCache

      public Object getValueFromCache(String cacheName, String key)
      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