接口 Cache

所有已知实现类:
DiskBasedCache, NoCache

public interface Cache
An interface for a cache keyed by a String with a byte array as data.
  • 嵌套类概要

    嵌套类
    修饰符和类型
    接口
    说明
    static class 
    Data and metadata for an entry returned by the cache.
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Empties the cache.
    get(String key)
    Retrieves an entry from the cache.
    void
    Performs any potentially long-running actions needed to initialize the cache; will be called from a worker thread.
    void
    invalidate(String key, boolean fullExpire)
    Invalidates an entry in the cache.
    void
    put(String key, Cache.Entry entry)
    Adds or replaces an entry to the cache.
    void
    Removes an entry from the cache.
  • 方法详细资料

    • get

      Cache.Entry get(String key)
      Retrieves an entry from the cache.
      参数:
      key - Cache key
      返回:
      An Cache.Entry or null in the event of a cache miss
    • put

      void put(String key, Cache.Entry entry)
      Adds or replaces an entry to the cache.
      参数:
      key - Cache key
      entry - Data to store and metadata for cache coherency, TTL, etc.
    • initialize

      void initialize()
      Performs any potentially long-running actions needed to initialize the cache; will be called from a worker thread.
    • invalidate

      void invalidate(String key, boolean fullExpire)
      Invalidates an entry in the cache.
      参数:
      key - Cache key
      fullExpire - True to fully expire the entry, false to soft expire
    • remove

      void remove(String key)
      Removes an entry from the cache.
      参数:
      key - Cache key
    • clear

      void clear()
      Empties the cache.