Interface DiskCache

All Known Implementing Classes:
DiskCacheAdapter, DiskLruCacheWrapper

public interface DiskCache
An interface for writing to and reading from a disk cache.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An interface for lazily creating a disk cache.
    static interface 
    An interface to actually write data to a key in the disk cache.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the cache.
    void
    delete(Key key)
    Remove the key and value from the cache.
    get(Key key)
    Get the cache for the value at the given key.
    void
    put(Key key, DiskCache.Writer writer)
    Write to a key in the cache.
  • Method Details

    • get

      @Nullable 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 point in time and we won't know about it.

      Parameters:
      key - The key in the cache.
      Returns:
      An InputStream representing the data at key at the time get is called.
    • put

      void put(Key key, DiskCache.Writer writer)
      Write to a key in the cache. DiskCache.Writer is used so that the cache implementation can perform 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

      void delete(Key key)
      Remove the key and value from the cache.
      Parameters:
      key - The key to remove.
    • clear

      void clear()
      Clear the cache.