dasahcc commented on a change in pull request #367: Add transient cache for
CustomRestClient implementation
URL: https://github.com/apache/helix/pull/367#discussion_r309467486
##########
File path:
helix-rest/src/main/java/org/apache/helix/rest/client/CustomRestClientImpl.java
##########
@@ -122,18 +144,23 @@ protected JsonNode getJsonObject(HttpResponse
httpResponse) throws IOException {
@VisibleForTesting
protected HttpResponse post(String url, Map<String, String> payloads) throws
IOException {
+ HttpPost postRequest = new HttpPost(url);
+ postRequest.setHeader("Accept", ACCEPT_CONTENT_TYPE);
+ StringEntity entity = new
StringEntity(OBJECT_MAPPER.writeValueAsString(payloads),
ContentType.APPLICATION_JSON);
+ postRequest.setEntity(entity);
+ HttpResponse httpResponse;
+ int hashCode = url.hashCode() + payloads.hashCode();
try {
- HttpPost postRequest = new HttpPost(url);
- postRequest.setHeader("Accept", ACCEPT_CONTENT_TYPE);
- StringEntity entity = new
StringEntity(OBJECT_MAPPER.writeValueAsString(payloads),
- ContentType.APPLICATION_JSON);
- postRequest.setEntity(entity);
+ if (_cachedResults.containsKey(hashCode)) {
Review comment:
Leave a TODO comments here. It is better to have response data processed
after caching. Otherwise, every single call still needs to process the
responses.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services