Package 

Interface DiskCache


  • 
    public interface DiskCache
    
                        

    An interface for writing to and reading from a disk cache.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface DiskCache.Factory

      An interface for lazily creating a disk cache.

      public interface DiskCache.Writer

      An interface to actually write data to a key in the disk cache.

    • Method Summary

      Modifier and Type Method Description
      abstract File get(Key key) Get the cache for the value at the given key.
      abstract void put(Key key, DiskCache.Writer writer) Write to a key in the cache.
      abstract void delete(Key key) Remove the key and value from the cache.
      abstract void clear() Clear the cache.
      • Methods inherited from class java.lang.Object

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

      • get

        @Nullable() abstract File get(Key key)

        Get the cache for the value at the given key.

        Note - This is potentially dangerous, someone may write a new value to the file at any pointin time and we won't know about it.

        Parameters:
        key - The key in the cache.
      • put

         abstract void put(Key key, DiskCache.Writer writer)

        Write to a key in the cache. Writer is used so that the cache implementation canperform actions after the write finishes, like commit (via atomic file rename).

        Parameters:
        key - The key to write to.
        writer - An interface that will write data given an OutputStream for the key.
      • delete

         abstract void delete(Key key)

        Remove the key and value from the cache.

        Parameters:
        key - The key to remove.
      • clear

         abstract void clear()

        Clear the cache.