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

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


        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
        final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
        CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
        final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
       
        CacheConfig config = new CacheConfig();
        config.setMaxUpdateRetries(0);
        impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                mockMemcachedCacheEntryFactory, mockKeyHashingScheme);

        HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(HttpCacheEntry old) {
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 MemcachedCacheEntryFactoryImpl(),
                new SHA256KeyHashingScheme());
    }
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

     * 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() {
        super.setUp();
        params = new CacheConfig();
        params.setMaxObjectSize(MAX_BYTES);

        if (CACHE_MANAGER.cacheExists(TEST_EHCACHE_NAME)){
            CACHE_MANAGER.removeCache(TEST_EHCACHE_NAME);
        }
View Full Code Here

        removeCache();
    }
   
    @Test
    public void testIssue1147() throws Exception {
        CacheConfig cacheConfig = new CacheConfig();
        cacheConfig.setSharedCache(true);
        cacheConfig.setMaxObjectSize(262144); //256kb

        ResourceFactory resourceFactory = new FileResourceFactory(cacheDir);
        HttpCacheStorage httpCacheStorage = new ManagedHttpCacheStorage(cacheConfig);

        HttpClient client = EasyMock.createMock(HttpClient.class);
View Full Code Here

   */
  public boolean cacheServiceStart(){
    cache = new Cache((long)2<<35, cachepath);
    IntermediateHttpClient HTTPClient = new IntermediateHttpClient();
    CacheCon  = new ThreadSafeClientConnManager();
    config = new CacheConfig();
    config.setSharedCache(true);
    config.setMaxObjectSizeBytes(2<<31);
    CacheClient = new CachingHttpClient(HTTPClient, cache, config);
    return false;
  }
View Full Code Here

        // This connection manager must be used if more than one thread will
        // be using the HttpClient.
   
    IntermediateHttpClient interClient = new IntermediateHttpClient();
    ((ThreadSafeClientConnManager)interClient.getConnectionManager()).setMaxTotal(100);
        CacheConfig config = new CacheConfig();
        config.setMaxObjectSizeBytes(2<<24);
        CachingHttpClient httpclient = new CachingHttpClient(new IntermediateHttpClient(), new Cache((long)2<<34, "places"), config);

        try {
            // create an array of URIs to perform GETs on
            String[] urisToGet = {
View Full Code Here

            hc.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler());
            hc.removeRequestInterceptorByClass(org.apache.http.protocol.RequestUserAgent.class);
            hc.addRequestInterceptor(new LMFRequestUserAgent(userAgentString));

            if (configurationService.getBooleanConfiguration("core.http.client_cache_enable", true)) {
                CacheConfig cacheConfig = new CacheConfig();
                // FIXME: Hardcoded constants - is this useful?
                cacheConfig.setMaxCacheEntries(1000);
                cacheConfig.setMaxObjectSize(81920);

                final HttpCacheStorage cacheStore = new EhcacheHttpCacheStorage(ehcache.get(), cacheConfig);

                this.httpClient = new MonitoredHttpClient(new CachingHttpClient(hc, cacheStore, cacheConfig));
            } else {
View Full Code Here

            hc.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler());
            hc.removeRequestInterceptorByClass(org.apache.http.protocol.RequestUserAgent.class);
            hc.addRequestInterceptor(new LMFRequestUserAgent(userAgentString));

            if (configurationService.getBooleanConfiguration(CoreOptions.HTTP_CLIENT_CACHE_ENABLE, true)) {
                CacheConfig cacheConfig = new CacheConfig();
                // FIXME: Hardcoded constants - is this useful?
                cacheConfig.setMaxCacheEntries(1000);
                cacheConfig.setMaxObjectSize(81920);

                final HttpCacheStorage cacheStore = new MapHttpCacheStorage(httpCache);

                this.httpClient = new MonitoredHttpClient(new CachingHttpClient(hc, cacheStore, cacheConfig));
            } else {
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.