Package org.microproxy.cache
Class HttpCache.Builder
java.lang.Object
org.microproxy.cache.HttpCache.Builder
- Enclosing class:
HttpCache
Options for
HttpCache.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates the configured HTTP cache.The clock for ages and freshness (for tests).The heuristic lifetime: this fraction of the time sinceLast-Modified, at mostmax.maxEntrySize(int bytes) The largest response body stored (default 8 MiB); larger ones stream past.The cache's name inCache-Status(default "MicroProxy").offline(boolean offline) Answer only from the cache, never contacting servers (default false).serveStaleOnError(boolean serveStaleOnError) Serve stale entries when servers cannot be reached (default true).shared(boolean shared) Whether the rules for shared caches apply (default true).store(CacheStore store) Where responses are kept (default: 64 MiB in memory).
-
Method Details
-
store
Where responses are kept (default: 64 MiB in memory).- Parameters:
store- the backing response store- Returns:
- this builder
-
maxEntrySize
The largest response body stored (default 8 MiB); larger ones stream past.- Parameters:
bytes- the maximum stored response body size in bytes- Returns:
- this builder
-
offline
Answer only from the cache, never contacting servers (default false).- Parameters:
offline- whether to answer only from cached responses- Returns:
- this builder
-
serveStaleOnError
Serve stale entries when servers cannot be reached (default true).- Parameters:
serveStaleOnError- whether stale responses may be served on upstream failures- Returns:
- this builder
-
heuristic
The heuristic lifetime: this fraction of the time sinceLast-Modified, at mostmax.- Parameters:
fraction- the fraction of time since Last-Modified used as a heuristic lifetimemax- the maximum heuristic freshness lifetime- Returns:
- this builder
-
clock
The clock for ages and freshness (for tests).- Parameters:
clock- the clock used for timestamps and expiry checks- Returns:
- this builder
-
name
The cache's name inCache-Status(default "MicroProxy").- Parameters:
name- the cache name reported in Cache-Status- Returns:
- this builder
-
build
Creates the configured HTTP cache.- Returns:
- the configured HTTP cache
-