Skip to content

Conversation

@sagarsane
Copy link

Added DEBUG and ERROR logs when there is a Cache HIT or MISS or in case of an exception.

Description

Related Issue

Related Issue: #43

Motivation and Context

To be able to investigate issues when GraphQL Client Cache Configuration is missing or has errors. Especially on AEM 6.5.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

@codecov
Copy link

codecov bot commented Jan 29, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (98a9828) 94.84% compared to head (8ea4271) 94.67%.

Files Patch % Lines
...ommerce/graphql/client/impl/GraphqlClientImpl.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #44      +/-   ##
============================================
- Coverage     94.84%   94.67%   -0.18%     
  Complexity      180      180              
============================================
  Files            11       11              
  Lines           485      488       +3     
  Branches         63       63              
============================================
+ Hits            460      462       +2     
- Misses           21       22       +1     
  Partials          4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@billdinger
Copy link

billdinger commented Jan 29, 2024

thanks much for this, will help triage miss(ed) cache hits and other cache weirdness

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to investigate whether GraphQL Client had a Cache HIT or MISS, missing logging

3 participants