Package org.microproxy.cache
Class MemoryCacheStore
java.lang.Object
org.microproxy.cache.MemoryCacheStore
- All Implemented Interfaces:
CacheStore
Keeps responses in memory, evicting the least recently used URLs beyond a size limit.
-
Constructor Summary
ConstructorsConstructorDescriptionMemoryCacheStore(long maxSize) Creates an in-memory store with a byte-weight limit. -
Method Summary
Modifier and TypeMethodDescriptionintcount()Returns the number of stored responses (variants).The stored variants forkey(a URL), most recently stored first; empty if none.voidput(CachedResponse response) Storesresponse, replacing the variant of its key with the samevaryvalues.voidRemoves every variant stored forkey.longsize()Returns the totalCachedResponse.weight()of what is stored.
-
Constructor Details
-
MemoryCacheStore
public MemoryCacheStore(long maxSize) Creates an in-memory store with a byte-weight limit.- Parameters:
maxSize- the mostCachedResponse.weight()to hold, in bytes
-
-
Method Details
-
get
Description copied from interface:CacheStoreThe stored variants forkey(a URL), most recently stored first; empty if none.- Specified by:
getin interfaceCacheStore- Parameters:
key- the URL whose variants to retrieve- Returns:
- the stored variants for
key(a URL), most recently stored first; empty if none
-
put
Description copied from interface:CacheStoreStoresresponse, replacing the variant of its key with the samevaryvalues.- Specified by:
putin interfaceCacheStore- Parameters:
response- the response being handled
-
remove
Description copied from interface:CacheStoreRemoves every variant stored forkey.- Specified by:
removein interfaceCacheStore- Parameters:
key- the URL whose variants to remove
-
size
public long size()Description copied from interface:CacheStoreReturns the totalCachedResponse.weight()of what is stored.- Specified by:
sizein interfaceCacheStore- Returns:
- the total
CachedResponse.weight()of what is stored
-
count
public int count()Description copied from interface:CacheStoreReturns the number of stored responses (variants).- Specified by:
countin interfaceCacheStore- Returns:
- the number of stored responses (variants)
-