Class JKTimedAndSizeCacheManager

java.lang.Object
com.jk.core.cache.simple.JKAbstractCacheManager
com.jk.core.cache.impl.JKTimedAndSizeCacheManager
All Implemented Interfaces:
JKCacheManager

public class JKTimedAndSizeCacheManager extends JKAbstractCacheManager
This class provides suitable methods used for caching and retrieval of data with specified life time while limiting the cache to certain number of entries.

It extends the JKAbstractCacheManager class.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKTimedAndSizeCacheManager

      public JKTimedAndSizeCacheManager()
  • Method Details

    • createCacheMap

      protected JKMap createCacheMap()
      This method constructs a new JKMap instance with the default maxCount and timeInSeconds specified using CacheBuilder
      Overrides:
      createCacheMap in class JKAbstractCacheManager
      Returns:
      the newly constructed JKMap.
    • getTimeInSeconds

      public int getTimeInSeconds()
      This methods returns the timeout time in which entries are automatically removed from the cache after it.
      Returns:
      the timeout value in seconds.
    • setTimeInSeconds

      public void setTimeInSeconds(int timeInSeconds)
      This methods sets the timeout time in which entries are automatically removed from the cache after it.
      Parameters:
      timeInSeconds - Specifies the timeout value in seconds.
    • getMaxCount

      public int getMaxCount()
      This methods gets the maximum number of entries the cache may contain.
      Returns:
      the maximum number of entries the cache may contain.
    • setMaxCount

      public void setMaxCount(int maxCount)
      This method sets the maximum number of entries the cache may contain.
      Parameters:
      maxCount - Specifies the maximum number of entries the cache may contain.
    • main

      public static void main(String[] args)
      This is the main method that demonstrates the usage of the JKTimedAndSizeCacheManager class.

      It sets up a cache manager, configures its maximum count and timeout, and performs cache operations.

      It also showcases cache retrieval and usage.

      Parameters:
      args - the command-line arguments.