Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,14 @@ public <T, U> GraphqlResponse<T, U> execute(GraphqlRequest request, Type typeOfT
if (cache != null) {
CacheKey key = new CacheKey(request, options);
try {
LOGGER.debug("Cache HIT : Returning response from cache for key {}", key);
return (GraphqlResponse<T, U>) cache.get(key, () -> executeImpl(request, typeOfT, typeofU, options));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pay attention to the fact that when 'cache' does don't have an entry for 'key' then it will execute the provided function in the second parameter of get() and if there's a valid response it will update the cache.
So your current approach is logging incorrectly both the cache hits and the cache misses.

} catch (ExecutionException e) {
LOGGER.error("Failed to return response from Cache", e);
return null;
}
}
LOGGER.debug("Cache MISS : Executing GraphQL call with Commerce");
return executeImpl(request, typeOfT, typeofU, options);
}

Expand Down