i3wangyi commented on a change in pull request #367: Add transient cache for CustomRestClient implementation URL: https://github.com/apache/helix/pull/367#discussion_r309475493
########## 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: It's a good suggestion. But keeping it HttpResponse is more general, gives us the ability to even add cache support for getInstance method. Converting from HttpResponse to output format is minor ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services