Interface Cache

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long IGNORE_AGE
      Negative value, to indicate that age does not matter.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Clears the cache and all other caches in the cache chain.
      void clear​(long maxAge)
      Clears the cache and all other caches in the cache chain.
      byte[] get​(URL requestURL, long maxAge)
      Retrieves an object from the cache.
      Cache getNextCache()
      Returns the next cache in a chain of caches.
      boolean isCached​(URL requestURL, long maxAge)
      Indicates whether a certain object is in the cache.
      void put​(URL requestURL, byte[] object)
      Puts an object into the cache.
      void setNextCache​(Cache nextCache)
      Registers the next cache.
    • Method Detail

      • get

        byte[] get​(URL requestURL,
                   long maxAge)
            throws IOException
        Retrieves an object from the cache.
        Parameters:
        requestURL - key
        maxAge - max age in ms, a negative value implies age does not matter.
        Returns:
        the object or null, if not found
        Throws:
        IOException - if an IOException occurs
      • put

        void put​(URL requestURL,
                 byte[] object)
          throws IOException
        Puts an object into the cache.
        Parameters:
        requestURL - key
        object - byte array to cache
        Throws:
        IOException - if an IOException occurs
      • getNextCache

        Cache getNextCache()
        Returns the next cache in a chain of caches.
        Returns:
        next cache or null
      • setNextCache

        void setNextCache​(Cache nextCache)
        Registers the next cache.
        Parameters:
        nextCache - next cache
      • isCached

        boolean isCached​(URL requestURL,
                         long maxAge)
                  throws IOException
        Indicates whether a certain object is in the cache.
        Parameters:
        requestURL - key
        maxAge - maximal allowed age in ms, a negative value implies age does not matter.
        Returns:
        true or false
        Throws:
        IOException - if an IOException occurs
      • clear

        void clear()
        Clears the cache and all other caches in the cache chain.
      • clear

        void clear​(long maxAge)
        Clears the cache and all other caches in the cache chain.
        Parameters:
        maxAge - clears only files older than maxAge ms