Class CacheConfig.Builder
- java.lang.Object
-
- org.apache.http.impl.client.cache.CacheConfig.Builder
-
- Enclosing class:
- CacheConfig
public static class CacheConfig.Builder extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CacheConfigbuild()CacheConfig.BuildersetAllow303Caching(boolean allow303Caching)Enables or disables 303 caching.CacheConfig.BuildersetAsynchronousWorkerIdleLifetimeSecs(int asynchronousWorkerIdleLifetimeSecs)Sets the current maximum idle lifetime in seconds for a background revalidation worker thread.CacheConfig.BuildersetAsynchronousWorkersCore(int asynchronousWorkersCore)Sets the minimum number of threads to keep alive for background revalidations due to thestale-while-revalidatedirective.CacheConfig.BuildersetAsynchronousWorkersMax(int asynchronousWorkersMax)Sets the maximum number of threads to allow for background revalidations due to thestale-while-revalidatedirective.CacheConfig.BuildersetHeuristicCachingEnabled(boolean heuristicCachingEnabled)Enables or disables heuristic caching.CacheConfig.BuildersetHeuristicCoefficient(float heuristicCoefficient)Sets coefficient to be used in heuristic freshness caching.CacheConfig.BuildersetHeuristicDefaultLifetime(long heuristicDefaultLifetime)Sets default lifetime in seconds to be used if heuristic freshness calculation is not possible.CacheConfig.BuildersetMaxCacheEntries(int maxCacheEntries)Sets the maximum number of cache entries the cache will retain.CacheConfig.BuildersetMaxObjectSize(long maxObjectSize)Specifies the maximum response body size that will be eligible for caching.CacheConfig.BuildersetMaxUpdateRetries(int maxUpdateRetries)Sets the number of times to retry a cache update on failureCacheConfig.BuildersetNeverCacheHTTP10ResponsesWithQueryString(boolean neverCacheHTTP10ResponsesWithQuery)Sets whether the cache should never cache HTTP 1.0 responses with a query string or not.CacheConfig.BuildersetRevalidationQueueSize(int revalidationQueueSize)Sets the current maximum queue size for background revalidations.CacheConfig.BuildersetSharedCache(boolean isSharedCache)Sets whether the cache should behave as a shared cache or not.CacheConfig.BuildersetWeakETagOnPutDeleteAllowed(boolean weakETagOnPutDeleteAllowed)Allows or disallows weak etags to be used with PUT/DELETE If-Match requests.
-
-
-
Method Detail
-
setMaxObjectSize
public CacheConfig.Builder setMaxObjectSize(long maxObjectSize)
Specifies the maximum response body size that will be eligible for caching.- Parameters:
maxObjectSize- size in bytes
-
setMaxCacheEntries
public CacheConfig.Builder setMaxCacheEntries(int maxCacheEntries)
Sets the maximum number of cache entries the cache will retain.
-
setMaxUpdateRetries
public CacheConfig.Builder setMaxUpdateRetries(int maxUpdateRetries)
Sets the number of times to retry a cache update on failure
-
setAllow303Caching
public CacheConfig.Builder setAllow303Caching(boolean allow303Caching)
Enables or disables 303 caching.- Parameters:
allow303Caching- should betrueto permit 303 caching,falseto disable it.
-
setWeakETagOnPutDeleteAllowed
public CacheConfig.Builder setWeakETagOnPutDeleteAllowed(boolean weakETagOnPutDeleteAllowed)
Allows or disallows weak etags to be used with PUT/DELETE If-Match requests.- Parameters:
weakETagOnPutDeleteAllowed- should betrueto permit weak etags,falseto reject them.
-
setHeuristicCachingEnabled
public CacheConfig.Builder setHeuristicCachingEnabled(boolean heuristicCachingEnabled)
Enables or disables heuristic caching.- Parameters:
heuristicCachingEnabled- should betrueto permit heuristic caching,falseto enable it.
-
setHeuristicCoefficient
public CacheConfig.Builder setHeuristicCoefficient(float heuristicCoefficient)
Sets coefficient to be used in heuristic freshness caching. This is interpreted as the fraction of the time between theLast-ModifiedandDateheaders of a cached response during which the cached response will be considered heuristically fresh.- Parameters:
heuristicCoefficient- should be between0.0and1.0.
-
setHeuristicDefaultLifetime
public CacheConfig.Builder setHeuristicDefaultLifetime(long heuristicDefaultLifetime)
Sets default lifetime in seconds to be used if heuristic freshness calculation is not possible. Explicit cache control directives on either the request or origin response will override this, as will the heuristicLast-Modifiedfreshness calculation if it is available.- Parameters:
heuristicDefaultLifetime- is the number of seconds to consider a cache-eligible response fresh in the absence of other information. Set this to0to disable this style of heuristic caching.
-
setSharedCache
public CacheConfig.Builder setSharedCache(boolean isSharedCache)
Sets whether the cache should behave as a shared cache or not.- Parameters:
isSharedCache- true to behave as a shared cache, false to behave as a non-shared (private) cache. To have the cache behave like a browser cache, you want to set this tofalse.
-
setAsynchronousWorkersMax
public CacheConfig.Builder setAsynchronousWorkersMax(int asynchronousWorkersMax)
Sets the maximum number of threads to allow for background revalidations due to thestale-while-revalidatedirective.- Parameters:
asynchronousWorkersMax- number of threads; a value of 0 disables background revalidations.
-
setAsynchronousWorkersCore
public CacheConfig.Builder setAsynchronousWorkersCore(int asynchronousWorkersCore)
Sets the minimum number of threads to keep alive for background revalidations due to thestale-while-revalidatedirective.- Parameters:
asynchronousWorkersCore- should be greater than zero and less than or equal togetAsynchronousWorkersMax()
-
setAsynchronousWorkerIdleLifetimeSecs
public CacheConfig.Builder setAsynchronousWorkerIdleLifetimeSecs(int asynchronousWorkerIdleLifetimeSecs)
Sets the current maximum idle lifetime in seconds for a background revalidation worker thread. If a worker thread is idle for this long, and there are more than the core number of worker threads alive, the worker will be reclaimed.- Parameters:
asynchronousWorkerIdleLifetimeSecs- idle lifetime in seconds
-
setRevalidationQueueSize
public CacheConfig.Builder setRevalidationQueueSize(int revalidationQueueSize)
Sets the current maximum queue size for background revalidations.
-
setNeverCacheHTTP10ResponsesWithQueryString
public CacheConfig.Builder setNeverCacheHTTP10ResponsesWithQueryString(boolean neverCacheHTTP10ResponsesWithQuery)
Sets whether the cache should never cache HTTP 1.0 responses with a query string or not.- Parameters:
neverCacheHTTP10ResponsesWithQuery- true to never cache responses with a query string, false to cache if explicit cache headers are found. Set this totrueto better emulate IE, which also never caches responses, regardless of what caching headers may be present.
-
build
public CacheConfig build()
-
-