问题
Using the org.apache.httpcomponents:httpasyncclient-cache:4.1.3
library, I'm trying to work out how I can create an asynchronous
caching
http client?
I can create each individually, using their respective builders, but I can't find a way to have both.
e.g.
CloseableHttpClient client = CachingHttpClientBuilder.create()
.setCacheConfig(cacheConfig())
.build();
CloseableHttpAsyncClient build = HttpAsyncClientBuilder.create()
.build();
Por que no los dos?
N.B. I'm not tied to this version of the library - happy for solutions using the latest version.
Related:
- How do I implement client side http caching like a browser?
回答1:
You can create a new CachingHttpAsyncClient
directly after you have built a HttpAsyncClient
. For example:
CloseableHttpAsyncClient asyncClient= HttpAsyncClientBuilder.create().build();
CachingHttpAsyncClient client = new CachingHttpAsyncClient(asyncClient, cacheConfig());
You can know more constructors from here.
来源:https://stackoverflow.com/questions/43623608/how-do-i-create-an-async-caching-http-client