Vertx HTTP客户端支持缓存

时间:2018-03-28 17:04:07

标签: vert.x vertx-httpclient

我想知道如何将缓存配置添加到Vertx http网络客户端。

使用Apache http客户端,我可以轻松设置setCacheConfig

PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(configuration.getMaxTotalConnections());
    connectionManager.setDefaultMaxPerRoute(configuration.getDefaultMaxConnectionsPerRoute());
    HttpHost httpHost = new HttpHost(configuration.getHost(), configuration.getPort());
    connectionManager.setMaxPerRoute(new HttpRoute(httpHost), configuration.getMaxConnectionsPerRoute());

    CacheConfig cacheConfig = CacheConfig.custom()
        .setMaxCacheEntries(configuration.getMaxCacheEntries())
        .setMaxObjectSize(configuration.getMaxCacheObjectSize())
        .build();
    RequestConfig requestConfig = RequestConfig.custom()
        .setConnectTimeout(configuration.getRequestConnectTimeout())
        .setSocketTimeout(configuration.getRequestSocketTimeout())
        .build();
    httpClient = CachingHttpClients.custom()
        .setCacheConfig(cacheConfig)
        .setDefaultRequestConfig(requestConfig)
        .setConnectionManager(connectionManager)
        .build();

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

从3.5.1开始不支持。您可以在Vert.x Web上提交问题。拉请求欢迎!