Package org.apache.http.impl.client.cache

Examples of org.apache.http.impl.client.cache.CacheConfig


     * Create a storage backend using the pre-configured given
     * <i>memcached</i> client.
     * @param cache client to use for communicating with <i>memcached</i>
     */
    public MemcachedHttpCacheStorage(MemcachedClientIF cache) {
        this(cache, new CacheConfig(), new DefaultHttpCacheEntrySerializer());
    }
View Full Code Here


     * Constructs a storage backend using the provided Ehcache
     * with default configuration options.
     * @param cache where to store cached origin responses
     */
    public EhcacheHttpCacheStorage(Ehcache cache) {
        this(cache, new CacheConfig(), new DefaultHttpCacheEntrySerializer());
    }
View Full Code Here

    @Override
    @Before
    public void setUp() throws Exception {
        mockMemcachedClient = EasyMock.createMock(MemcachedClientIF.class);
        mockSerializer = EasyMock.createMock(HttpCacheEntrySerializer.class);
        CacheConfig config = new CacheConfig();
        config.setMaxUpdateRetries(1);
        impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                mockSerializer);
    }
View Full Code Here

     * Create a storage backend using the pre-configured given
     * <i>memcached</i> client.
     * @param cache client to use for communicating with <i>memcached</i>
     */
    public MemcachedHttpCacheStorage(MemcachedClientIF cache) {
        this(cache, new CacheConfig(), new DefaultHttpCacheEntrySerializer());
    }
View Full Code Here

        mockMemcachedCacheEntryFactory = EasyMock.createNiceMock(MemcachedCacheEntryFactory.class);
        mockMemcachedCacheEntry = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        mockMemcachedCacheEntry2 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        mockMemcachedCacheEntry3 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        mockMemcachedCacheEntry4 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        final CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(1).build();
        impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                mockMemcachedCacheEntryFactory, mockKeyHashingScheme);
    }
View Full Code Here

        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
        final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
        final CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
        final byte[] newBytes = HttpTestUtils.getRandomBytes(128);

        final CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(0).build();
        impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                mockMemcachedCacheEntryFactory, mockKeyHashingScheme);

        final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(final HttpCacheEntry old) {
View Full Code Here

      }
      // Set up cookies
      defaultClient.setCookieStore(cookieStore);
      // Set up caching
      if (settings.getCacheExpiration() >= 0L) {
        CacheConfig cacheConfig = new CacheConfig();
        cacheConfig.setMaxCacheEntries(1000);
        cacheConfig.setHeuristicCachingEnabled(true);
        cacheConfig.setHeuristicDefaultLifetime(
            settings.getCacheExpiration());
        cacheConfig.setHeuristicCoefficient(0.9f);
        CachingHttpClient cachingClient = new CachingHttpClient(
            defaultClient, cacheConfig);
        return cachingClient;
      } else {
        return defaultClient;
View Full Code Here

      int socketTimeout = readFromProperty("bdSocketTimeout", globalTimeout);
      RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT).setConnectTimeout(connectTimeout)
        .setSocketTimeout(socketTimeout).setConnectionRequestTimeout(connectionRequestTimeout).build();

      // configure caching
      CacheConfig cacheConfig = CacheConfig.copy(CacheConfig.DEFAULT).setSharedCache(false).setMaxCacheEntries(1000)
        .setMaxObjectSize(2 * 1024 * 1024).build();

      // create the HTTP client
      return CachingHttpClientBuilder.create().setCacheConfig(cacheConfig).setSslcontext(sslContext)
        .setDefaultRequestConfig(requestConfig).build();
View Full Code Here

    private HttpCacheEntrySerializer mockSerializer;

    @Override
    public void setUp() {
        mockCache = EasyMock.createNiceMock(Ehcache.class);
        final CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(1).build();
        mockSerializer = EasyMock.createNiceMock(HttpCacheEntrySerializer.class);
        impl = new EhcacheHttpCacheStorage(mockCache, config, mockSerializer);
    }
View Full Code Here

        mockMemcachedCacheEntryFactory = EasyMock.createNiceMock(MemcachedCacheEntryFactory.class);
        mockMemcachedCacheEntry = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        mockMemcachedCacheEntry2 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        mockMemcachedCacheEntry3 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        mockMemcachedCacheEntry4 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
        final CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(1).build();
        impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                mockMemcachedCacheEntryFactory, mockKeyHashingScheme);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.cache.CacheConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.