Class DiskLruCacheWrapper

  • All Implemented Interfaces:
    DiskCache

    public class DiskLruCacheWrapper
    extends java.lang.Object
    implements DiskCache
    The default DiskCache implementation. There must be no more than one active instance for a given directory at a time.
    See Also:
    get(java.io.File, long)
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DiskLruCacheWrapper​(java.io.File directory, long maxSize)
      Deprecated.
      Do not extend this class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void clear()
      Clear the cache.
      static DiskCache create​(java.io.File directory, long maxSize)
      Create a new DiskCache in the given directory with a specified max size.
      void delete​(Key key)
      Remove the key and value from the cache.
      java.io.File get​(Key key)
      Get the cache for the value at the given key.
      static DiskCache get​(java.io.File directory, long maxSize)
      Deprecated.
      Use create(File, long) to create a new cache with the specified arguments.
      void put​(Key key, DiskCache.Writer writer)
      Write to a key in the cache.
      • Methods inherited from class java.lang.Object

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

      • DiskLruCacheWrapper

        @Deprecated
        protected DiskLruCacheWrapper​(java.io.File directory,
                                      long maxSize)
        Deprecated.
        Do not extend this class.
    • Method Detail

      • get

        @Deprecated
        public static DiskCache get​(java.io.File directory,
                                    long maxSize)
        Deprecated.
        Use create(File, long) to create a new cache with the specified arguments.
        Get a DiskCache in the given directory and size. If a disk cache has already been created with a different directory and/or size, it will be returned instead and the new arguments will be ignored.
        Parameters:
        directory - The directory for the disk cache
        maxSize - The max size for the disk cache
        Returns:
        The new disk cache with the given arguments, or the current cache if one already exists
      • create

        public static DiskCache create​(java.io.File directory,
                                       long maxSize)
        Create a new DiskCache in the given directory with a specified max size.
        Parameters:
        directory - The directory for the disk cache
        maxSize - The max size for the disk cache
        Returns:
        The new disk cache with the given arguments
      • get

        public java.io.File get​(Key key)
        Description copied from interface: DiskCache
        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.

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

        public void put​(Key key,
                        DiskCache.Writer writer)
        Description copied from interface: DiskCache
        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).
        Specified by:
        put in interface DiskCache
        Parameters:
        key - The key to write to.
        writer - An interface that will write data given an OutputStream for the key.
      • delete

        public void delete​(Key key)
        Description copied from interface: DiskCache
        Remove the key and value from the cache.
        Specified by:
        delete in interface DiskCache
        Parameters:
        key - The key to remove.
      • clear

        public void clear()
        Description copied from interface: DiskCache
        Clear the cache.
        Specified by:
        clear in interface DiskCache