Class CacheManager


  • public final class CacheManager
    extends Object
    Cache Utils class.
    • Constructor Detail

      • CacheManager

        public CacheManager()
    • Method Detail

      • cacheObject

        public <T> void cacheObject​(String cacheKey,
                                    T object)
        Caches the given object.
        Type Parameters:
        T - the class object type.
        Parameters:
        cacheKey - the cache key.
        object - the object to cache.
      • cacheObject

        public <T> void cacheObject​(String cacheKey,
                                    T object,
                                    Object defaultValue)
        Caches the given object.
        Type Parameters:
        T - the class object type.
        Parameters:
        cacheKey - the cache key.
        object - the object to cache.
        defaultValue - a default value to add to cache if the object it null
      • getFromCache

        public <T> Optional<T> getFromCache​(String cacheKey,
                                            Class<? extends T> objectClass)
        Retrieves an object from cache.
        Type Parameters:
        T - the class object type.
        Parameters:
        cacheKey - the cache key.
        objectClass - the class of the object to return.
        Returns:
        the cached object or Optional.empty() if not existing.
      • removeFromCache

        public void removeFromCache​(String cacheKey)
        Removes an object from cache.
        Parameters:
        cacheKey - the cache key.