Leon-WTF commented on pull request #2225:
URL: https://github.com/apache/drill/pull/2225#issuecomment-874750796


   Thanks cong,just if we use queryId as the cache key, it may conflict when 
two users upload different profile jsons with same query id at the same 
time(Though this may be a rare condition). What do you think?
   
   > @Leon-WTF Hi. I think we made things complicated. There is a suggestion to 
revise :
   > 
   > 1. Define the cache above the `getProfileJSON(@PathParam("queryid") String 
queryId)`
   > 
   > ```java
   >   // provide cache for view the profile
   >   private static final Cache<String, String> PROFILE_CACHE =
   >       CacheBuilder
   >         .newBuilder()
   >           .expireAfterAccess(1, TimeUnit.MINUTES)
   >             .build();
   > ```
   > 
   > 1. Add the if-else in the `getProfileJSON(@PathParam("queryid") String 
queryId)`
   > 
   > ```java
   > String content = PROFILE_CACHE.getIfPresent(queryId);
   > if (content == null) {
   >  // return the new
   > } else {
   >   PROFILE_CACHE.invalidate(queryId);
   >   // then, return the cache
   > }
   > ```
   > 
   > 1. Cache the data in the `viewProfile(@FormDataParam(PROFILE_DATA) String 
content)`
   > 
   > ```java
   > PROFILE_CACHE.put(profile.getQueryId(), content);
   > ```


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to