Class JKAbstractCacheManager

java.lang.Object
com.jk.core.cache.simple.JKAbstractCacheManager
All Implemented Interfaces:
JKCacheManager
Direct Known Subclasses:
JKDefaultCacheManager, JKTimedAndSizeCacheManager

public abstract class JKAbstractCacheManager extends Object implements JKCacheManager
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
    Modifier and Type
    Field
    Description
    protected JKLogger
    Represents this class logger.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    This method transform JKCacheManager into a map.
    void
    cache(Object key, Object object)
    This method caches data with the specified key inside the JKCacheManager object instance.
    <T> void
    cache(Object key, Object object, Class<T> clas)
    This method caches data with the associated key inside the specified cached data container.
    void
    This method clears all the data cached inside the JKCacheManager.
    void
    clear(Class<?> clas)
    This method clears the data cached inside the specified data type.
    protected JKMap<Object,Object>
    This method creates a new cache map for the JKAbstractCacheManager.
    <T> T
    get(Object key, Class<T> clas)
    This method gets the cached data associated with the specified key, and stored in the specified data container type.
    <T> List<T>
    get(String key)
    This method gets the cached data container that is associated with the specified key as a list.
    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 this JKAbstractCacheManager allow null values or not.
    boolean
    isAvailable(Object key, Class<?> clas)
    This method checks whether the specified cached data is available or not.
    void
    remove(Object key, Class<?> clas)
    This method removes the cached data from JKCacheManager.
    void
    This method removes the cached data associated with the specified key from JKCacheManager.
    void
    setAllowNullable(boolean allowNullable)
    This method changes the value which specify whether this JKAbstractCacheManager allows null value or not.

    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

      protected JKLogger logger
      Represents this class logger.
  • Constructor Details

    • JKAbstractCacheManager

      public JKAbstractCacheManager()
  • Method Details

    • cache

      public void cache(Object key, Object object)
      This method caches data with the specified key inside the JKCacheManager object instance.
      Specified by:
      cache in interface JKCacheManager
      Parameters:
      key - Specifies the key of the cached data.
      object - Specifies the cached data.
    • cache

      public <T> void cache(Object key, Object object, Class<T> clas)
      This method caches data with the associated key inside the specified cached data container.
      Specified by:
      cache in interface JKCacheManager
      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

      public void clear(Class<?> clas)
      This method clears the data cached inside the specified data type.
      Specified by:
      clear in interface JKCacheManager
      Parameters:
      clas - Specifies the data type to be cleared.
    • get

      public <T> List<T> get(String key)
      This method gets the cached data container that is associated with the specified key as a list.
      Specified by:
      get in interface JKCacheManager
      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

      public <T> T get(Object key, Class<T> clas)
      This method gets the cached data associated with the specified key, and stored in the specified data container type.
      Specified by:
      get in interface JKCacheManager
      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

      public JKMap<Object,Object> getCachableMap(Class<?> clas)
      This method gets the cached data container as a map.
      Specified by:
      getCachableMap in interface JKCacheManager
      Parameters:
      clas - Specifies the cached data container type.
      Returns:
      a map with the specified cached data.
    • createCacheMap

      protected JKMap<Object,Object> createCacheMap()
      This method creates a new cache map for the JKAbstractCacheManager.
      Returns:
      the new cache map.
    • isAllowNullable

      public boolean isAllowNullable()
      This method checks whether this JKAbstractCacheManager allow null values or not.
      Returns:
      true, if it allows null values, false, otherwise.
    • isAvailable

      public boolean isAvailable(Object key, Class<?> clas)
      This method checks whether the specified cached data is available or not.
      Specified by:
      isAvailable in interface JKCacheManager
      Parameters:
      key - Specifies the id of the cached data.
      clas - Specifies the cached data container type.
      Returns:
      true, if is available, false otherwise.
    • remove

      public void remove(Object key, Class<?> clas)
      This method removes the cached data from JKCacheManager.
      Specified by:
      remove in interface JKCacheManager
      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 this JKAbstractCacheManager 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 the JKCacheManager.
      Specified by:
      clear in interface JKCacheManager
    • remove

      public void remove(String key)
      This method removes the cached data associated with the specified key from JKCacheManager.
      Specified by:
      remove in interface JKCacheManager
      Parameters:
      key - Specifies the key associated with the cached data.
    • getCacheClasses

      public Set<Class<?>> getCacheClasses()
      This method returns a set of all the currently cached classes.
      Specified by:
      getCacheClasses in interface JKCacheManager
      Returns:
      a set of all the currently cached classes.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asMap

      public Map asMap()
      This method transform JKCacheManager into a map.
      Specified by:
      asMap in interface JKCacheManager
      Returns:
      a map that represents the JKCachedManager