如何创建异步缓存的HTTP客户端? [英] How do I create an async caching http client?

查看:185
本文介绍了如何创建异步缓存的HTTP客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 org.apache.httpcomponents:httpasyncclient-cache:4.1.3 库,我试图弄清楚如何创建异步 缓存 http客户端?

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.

CloseableHttpClient client = CachingHttpClientBuilder.create()
    .setCacheConfig(cacheConfig())
    .build();







CloseableHttpAsyncClient build = HttpAsyncClientBuilder.create()
    .build();

没有问题吗?

NB 我不依赖于此版本的库-对于使用最新版本的解决方案感到满意。

N.B. I'm not tied to this version of the library - happy for solutions using the latest version.

相关:

  • How do I implement client side http caching like a browser?

推荐答案

在构建 HttpAsyncClient CachingHttpAsyncClient c>。例如:

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());

您可以从此处

这篇关于如何创建异步缓存的HTTP客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆