Class MemoryCacheStore

java.lang.Object
org.microproxy.cache.MemoryCacheStore
All Implemented Interfaces:
CacheStore

public final class MemoryCacheStore extends Object implements CacheStore
Keeps responses in memory, evicting the least recently used URLs beyond a size limit.
  • Constructor Details

    • MemoryCacheStore

      public MemoryCacheStore(long maxSize)
      Creates an in-memory store with a byte-weight limit.
      Parameters:
      maxSize - the most CachedResponse.weight() to hold, in bytes
  • Method Details

    • get

      public List<CachedResponse> get(String key)
      Description copied from interface: CacheStore
      The stored variants for key (a URL), most recently stored first; empty if none.
      Specified by:
      get in interface CacheStore
      Parameters:
      key - the URL whose variants to retrieve
      Returns:
      the stored variants for key (a URL), most recently stored first; empty if none
    • put

      public void put(CachedResponse response)
      Description copied from interface: CacheStore
      Stores response, replacing the variant of its key with the same vary values.
      Specified by:
      put in interface CacheStore
      Parameters:
      response - the response being handled
    • remove

      public void remove(String key)
      Description copied from interface: CacheStore
      Removes every variant stored for key.
      Specified by:
      remove in interface CacheStore
      Parameters:
      key - the URL whose variants to remove
    • size

      public long size()
      Description copied from interface: CacheStore
      Returns the total CachedResponse.weight() of what is stored.
      Specified by:
      size in interface CacheStore
      Returns:
      the total CachedResponse.weight() of what is stored
    • count

      public int count()
      Description copied from interface: CacheStore
      Returns the number of stored responses (variants).
      Specified by:
      count in interface CacheStore
      Returns:
      the number of stored responses (variants)