Sam*_*Sam 4 http restlet http-caching resteasy
我使用RESTFul服务作为我的前端的后端.该服务在其响应上设置expires/etag/lastmodified标头.
我正在寻找的是一个客户端(有利的java)库,它可以从服务中获取数据并将其缓存在可插入的缓存后端,如ehcache.
我还希望能够做的是在条目无效时使用后台工作线程自动填充缓存.此外,做条件GET应该是明智的.
我遇到过 http://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html
有没有人知道的其他图书馆?这不是一个相当普遍的问题吗?
Ric*_*ell 10
Apache HttpComponents库的4.0+版本附带HTTP 1.1缓存支持.您可以将它与Spring RestTemplate restful client一起使用,如下所示:
CacheConfig cacheConfig = new CacheConfig();
cacheConfig.setMaxCacheEntries(1000);
cacheConfig.setMaxObjectSize(8192);
HttpClient cachingClient = new CachingHttpClient(new DefaultHttpClient(), cacheConfig);
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(cachingClient);
RestTemplate rest = new RestTemplate(requestFactory);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4184 次 |
| 最近记录: |