Class Cache<T>


  • public class Cache<T>
    extends java.lang.Object
    Create a cache, that tracks its age. Additionally, a 'shared cache' is created. Caches can be added to this shared space and retrieved at any time.
    • Constructor Summary

      Constructors 
      Constructor Description
      Cache()
      Create a cache with the default age of 10 minutes.
      Cache​(long age)
      Create a chace with an arbitrary age (in seconds).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long age()
      Fetch the maximum age before this cache is considered old.
      Cache<T> age​(long age)
      Set the maximum age before this cache is considered old.
      T data()
      Fetch the data that is cached
      Cache<T> data​(T new_cache)
      Set the data that is cached, and updates when the cache was updated.
      static Cache delete​(java.lang.String name)
      Remove a cache from the shared cache.
      static Cache<java.util.Hashtable<java.lang.String,​java.lang.String>> fetch_hashtable_cache​(java.lang.String name)
      Fetch a cache, containing a Hashtable for data, from the shared cache.
      static Cache<java.util.Hashtable<java.lang.String,​java.lang.String>> fetch_hashtable_cache​(java.lang.String name, long age)
      Fetch a cache, containing a Hashtable for data, from the shared cache.
      void invalidate()
      Flag this cache as 'old'.
      java.lang.Boolean is_old()
      Test the cache's age.
      static java.lang.Boolean is_old​(java.lang.String name)
      Test a shared cache's age.
      java.util.Date last_update()
      Fetch the maximum age before this cache is considered old.
      static Cache shared​(java.lang.String name)
      Fetch a cache from the shared cache.
      static void shared​(java.lang.String name, Cache cache)
      Add/Update a cache to the shared cache.
      java.lang.Long size()  
      • Methods inherited from class java.lang.Object

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

      • Cache

        public Cache()
        Create a cache with the default age of 10 minutes.
      • Cache

        public Cache​(long age)
        Create a chace with an arbitrary age (in seconds).
    • Method Detail

      • last_update

        public java.util.Date last_update()
        Fetch the maximum age before this cache is considered old.
      • age

        public long age()
        Fetch the maximum age before this cache is considered old.
      • age

        public Cache<T> age​(long age)
        Set the maximum age before this cache is considered old.
      • data

        public T data()
        Fetch the data that is cached
      • data

        public Cache<T> data​(T new_cache)
        Set the data that is cached, and updates when the cache was updated.
      • is_old

        public java.lang.Boolean is_old()
        Test the cache's age. If the data hasn't yet been set, it is considered 'old'.
      • invalidate

        public void invalidate()
        Flag this cache as 'old'.
      • size

        public java.lang.Long size()
      • shared

        public static void shared​(java.lang.String name,
                                  Cache cache)
        Add/Update a cache to the shared cache.
      • shared

        public static Cache shared​(java.lang.String name)
        Fetch a cache from the shared cache.
      • delete

        public static Cache delete​(java.lang.String name)
        Remove a cache from the shared cache. If the cache doesn't exist, nothing is done.
        Returns:
        The cache that was removed (if one was removed).
      • is_old

        public static java.lang.Boolean is_old​(java.lang.String name)
        Test a shared cache's age. If the cache name doesn't exist, it is considered old.
        See Also:
        is_old()
      • fetch_hashtable_cache

        public static Cache<java.util.Hashtable<java.lang.String,​java.lang.String>> fetch_hashtable_cache​(java.lang.String name)
        Fetch a cache, containing a Hashtable for data, from the shared cache. If it doesn't exist, it will be created (using the default age) before returning.
        Parameters:
        name - The name of the shared cache to create and/or fetch
        Returns:
        a Cache>
      • fetch_hashtable_cache

        public static Cache<java.util.Hashtable<java.lang.String,​java.lang.String>> fetch_hashtable_cache​(java.lang.String name,
                                                                                                                long age)
        Fetch a cache, containing a Hashtable for data, from the shared cache. If it doesn't exist, it will be created (using the specified age) before returning.
        Parameters:
        name - The name of the shared cache to create and/or fetch
        age - The age of the shared cache being created. If the cache already exists, the value of this parameter will have no effect.
        Returns:
        a Cache>