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 Type
    Method
    Description
    This method transform JKCacheManager into a map.
    void
    cache(Object key, Object cache)
    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.
    <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.
    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>
    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
    isAvailable(Object id, 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.
  • Method Details

    • cache

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

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

      <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.
      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

      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.

      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

      JKMap<Object,?> getCachableMap(Class<?> clas)
      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

      boolean isAvailable(Object id, Class<?> clas)
      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

      void remove(Object key, Class<?> clas)
      This method removes the cached data from JKCacheManager.
      Parameters:
      key - Specifies the key of the cached data.
      clas - Specifies the cached data container type.
    • cache

      <T> void cache(Object key, Object object, Class<T> clas)
      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 the JKCacheManager.
    • remove

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

      Set<Class<?>> 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 transform JKCacheManager into a map.
      Returns:
      a map that represents the JKCachedManager
    • get

      <T> List<T> get(String key)
      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.