Class LRUCache

    • Constructor Detail

      • LRUCache

        public LRUCache​(int capacity)
        Parameters:
        capacity - capacity of this cache
    • Method Detail

      • isWriteThrough

        public boolean isWriteThrough()
      • setWriteThrough

        public void setWriteThrough​(boolean writeThrough)
      • getNextCache

        public Cache getNextCache()
        Description copied from interface: Cache
        Returns the next cache in a chain of caches.
        Specified by:
        getNextCache in interface Cache
        Returns:
        next cache or null
      • setNextCache

        public void setNextCache​(Cache nextCache)
        Description copied from interface: Cache
        Registers the next cache.
        Specified by:
        setNextCache in interface Cache
        Parameters:
        nextCache - next cache
      • isCached

        public boolean isCached​(URL requestURL,
                                long maxAge)
                         throws IOException
        Description copied from interface: Cache
        Indicates whether a certain object is in the cache.
        Specified by:
        isCached in interface 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

        public void clear​(long maxAge)
        Description copied from interface: Cache
        Clears the cache and all other caches in the cache chain.
        Specified by:
        clear in interface Cache
        Parameters:
        maxAge - clears only files older than maxAge ms
      • clear

        public void clear()
        Description copied from interface: Cache
        Clears the cache and all other caches in the cache chain.
        Specified by:
        clear in interface Cache
      • get

        public byte[] get​(URL requestURL,
                          long maxAge)
                   throws IOException
        Description copied from interface: Cache
        Retrieves an object from the cache.
        Specified by:
        get in interface 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

        public void put​(URL requestURL,
                        byte[] object)
                 throws IOException
        Description copied from interface: Cache
        Puts an object into the cache.
        Specified by:
        put in interface Cache
        Parameters:
        requestURL - key
        object - byte array to cache
        Throws:
        IOException - if an IOException occurs