Package 

Class CacheManager

  • All Implemented Interfaces:

    
    public class CacheManager
    
                        

    CacheManager for simple storing and accessing of values in cache files.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void destroy() Destroy ALL items in the cache.
      static synchronized void destroy(String id) Delete an item by its id.
      static void destroyOld() Destroy old cache items that expired.
      static <X> X get(String id, Class<X> classOf, Callable<X> callable) Get something out of the cache.
      static <X> X get(String id, Class<X> classOf, Callable<X> callable, int validUntil) Get something out of the cache.
      static synchronized <X> void store(String id, X value) Store something in the cache.
      static synchronized <X> void store(String id, X value, int validUntil) Store something in the cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • destroy

         static void destroy()

        Destroy ALL items in the cache.

      • destroy

         static synchronized void destroy(String id)

        Delete an item by its id.

        Parameters:
        id - The id of the cache item.
      • destroyOld

         static void destroyOld()

        Destroy old cache items that expired.

      • get

         static <X> X get(String id, Class<X> classOf, Callable<X> callable)

        Get something out of the cache. If it's not existing the callable will be called for new data which will then be stored in the cache. If something new is cached it will be stored for 3600 seconds.

        Parameters:
        id - The id of the cache item.
        classOf - The class of the value which should be cached.
        callable - The callable if the cache is empty to get a new value.
      • get

         static <X> X get(String id, Class<X> classOf, Callable<X> callable, int validUntil)

        Get something out of the cache. If it's not existing the callable will be called for new data which will then be stored in the cache.

        Parameters:
        id - The id of the cache item.
        classOf - The class of the value which should be cached.
        callable - The callable if the cache is empty to get a new value.
        validUntil - How long the cache should be valid.
      • store

         static synchronized <X> void store(String id, X value)

        Store something in the cache. This function will cache for 3600 seconds (one hour).

        Parameters:
        id - The id of the cache item.
        value - The value to store in the cache.
      • store

         static synchronized <X> void store(String id, X value, int validUntil)

        Store something in the cache.

        Parameters:
        id - The id of the cache item.
        value - The value to store in the cache.
        validUntil - How long the cache should be valid.