hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1487) CachingHttpClient doesn't persist cache
Date Wed, 19 Mar 2014 08:57:47 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13940315#comment-13940315
] 

Oleg Kalnichevski commented on HTTPCLIENT-1487:
-----------------------------------------------

@Chris 
In default configuration caching HttpClient deletes cache entries in disk when shut down.
I personally do not think this is unreasonable. 
{code:java}
CacheConfig config = CacheConfig.DEFAULT;
CloseableHttpClient client = CachingHttpClients.custom()
    .setCacheConfig(config)
    .setCacheDir(new File("my-cache"))
    .build();
{code}

One can override the default behavior by managing cache storage manually.
{code:java}
CacheConfig config = CacheConfig.DEFAULT;
FileResourceFactory resourceFactory = new FileResourceFactory(new File("my-cache"));
ManagedHttpCacheStorage cacheStorage = new ManagedHttpCacheStorage(config);
CloseableHttpClient client = CachingHttpClients.custom()
        .setCacheConfig(config)
        .setResourceFactory(resourceFactory)
        .setHttpCacheStorage(cacheStorage)
        .build();

// This will not affect cache storage
client.close();
// use #cleanResources instead of #close to preserve valid cache entries
cacheStorage.cleanResources();
//cacheStorage.close();    
{code}

Oleg

> CachingHttpClient doesn't persist cache
> ---------------------------------------
>
>                 Key: HTTPCLIENT-1487
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1487
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>            Reporter: Chris Oliver
>            Assignee: Jon Moore
>            Priority: Blocker
>
> Unless I'm mistaken, the current implementation doesn't maintain the cache between executions
of the java process. In addition, it appears the current api for HttpCacheStorage makes it
difficult / error prone to do this myself, since my implementation would have to somehow produce
an HttpCacheEntry. Any suggestions?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message