类 DiskBasedCache

java.lang.Object
com.android.volley.toolbox.DiskBasedCache
所有已实现的接口:
Cache

public class DiskBasedCache extends Object implements Cache
Cache implementation that caches files directly onto the hard disk in the specified directory. The default disk usage size is 5MB, but is configurable.
  • 嵌套类概要

    从接口继承的嵌套类/接口 com.android.volley.Cache

    Cache.Entry
  • 构造器概要

    构造器
    构造器
    说明
    DiskBasedCache(File rootDirectory)
    Constructs an instance of the DiskBasedCache at the specified directory using the default maximum cache size of 5MB.
    DiskBasedCache(File rootDirectory, int maxCacheSizeInBytes)
    Constructs an instance of the DiskBasedCache at the specified directory.
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Clears the cache.
    get(String key)
    Returns the cache entry with the specified key if it exists, null otherwise.
    Returns a file object for the given cache key.
    void
    Initializes the DiskBasedCache by scanning for all files currently in the specified root directory.
    void
    invalidate(String key, boolean fullExpire)
    Invalidates an entry in the cache.
    void
    put(String key, Cache.Entry entry)
    Puts the entry with the specified key into the cache.
    void
    Removes the specified key from the cache if it exists.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • DiskBasedCache

      public DiskBasedCache(File rootDirectory, int maxCacheSizeInBytes)
      Constructs an instance of the DiskBasedCache at the specified directory.
      参数:
      rootDirectory - The root directory of the cache.
      maxCacheSizeInBytes - The maximum size of the cache in bytes.
    • DiskBasedCache

      public DiskBasedCache(File rootDirectory)
      Constructs an instance of the DiskBasedCache at the specified directory using the default maximum cache size of 5MB.
      参数:
      rootDirectory - The root directory of the cache.
  • 方法详细资料

    • clear

      public void clear()
      Clears the cache. Deletes all cached files from disk.
      指定者:
      clear 在接口中 Cache
    • get

      public Cache.Entry get(String key)
      Returns the cache entry with the specified key if it exists, null otherwise.
      指定者:
      get 在接口中 Cache
      参数:
      key - Cache key
      返回:
      An Cache.Entry or null in the event of a cache miss
    • initialize

      public void initialize()
      Initializes the DiskBasedCache by scanning for all files currently in the specified root directory. Creates the root directory if necessary.
      指定者:
      initialize 在接口中 Cache
    • invalidate

      public void invalidate(String key, boolean fullExpire)
      Invalidates an entry in the cache.
      指定者:
      invalidate 在接口中 Cache
      参数:
      key - Cache key
      fullExpire - True to fully expire the entry, false to soft expire
    • put

      public void put(String key, Cache.Entry entry)
      Puts the entry with the specified key into the cache.
      指定者:
      put 在接口中 Cache
      参数:
      key - Cache key
      entry - Data to store and metadata for cache coherency, TTL, etc.
    • remove

      public void remove(String key)
      Removes the specified key from the cache if it exists.
      指定者:
      remove 在接口中 Cache
      参数:
      key - Cache key
    • getFileForKey

      public File getFileForKey(String key)
      Returns a file object for the given cache key.