Example usage for org.apache.http.impl.client.cache ResponseCachingPolicy ResponseCachingPolicy

List of usage examples for org.apache.http.impl.client.cache ResponseCachingPolicy ResponseCachingPolicy

Introduction

In this page you can find the example usage for org.apache.http.impl.client.cache ResponseCachingPolicy ResponseCachingPolicy.

Prototype

public ResponseCachingPolicy(int maxObjectSizeBytes, boolean sharedCache) 

Source Link

Document

Define a cache policy that limits the size of things that should be stored in the cache to a maximum of HttpResponse bytes in size.

Usage

From source file:org.apache.http.impl.client.cache.CachingHttpClient.java

CachingHttpClient(HttpClient client, HttpCache cache, CacheConfig config) {
    super();/*from  w  w w  .ja  va  2s  . c o  m*/
    if (client == null) {
        throw new IllegalArgumentException("HttpClient may not be null");
    }
    if (cache == null) {
        throw new IllegalArgumentException("HttpCache may not be null");
    }
    if (config == null) {
        throw new IllegalArgumentException("CacheConfig may not be null");
    }
    this.maxObjectSizeBytes = config.getMaxObjectSizeBytes();
    this.sharedCache = config.isSharedCache();
    this.backend = client;
    this.responseCache = cache;
    this.validityPolicy = new CacheValidityPolicy();
    this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes, sharedCache);
    this.responseGenerator = new CachedHttpResponseGenerator(this.validityPolicy);
    this.cacheableRequestPolicy = new CacheableRequestPolicy();
    this.suitabilityChecker = new CachedResponseSuitabilityChecker(this.validityPolicy, config);
    this.conditionalRequestBuilder = new ConditionalRequestBuilder();

    this.responseCompliance = new ResponseProtocolCompliance();
    this.requestCompliance = new RequestProtocolCompliance();

    this.asynchRevalidator = makeAsynchronousValidator(config);
}