-
Notifications
You must be signed in to change notification settings - Fork 554
Avoid adding values to cache if the current value is the same as adding value #6673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
PR builder started |
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #6673 +/- ##
============================================
- Coverage 48.41% 48.11% -0.30%
+ Complexity 16512 16177 -335
============================================
Files 1833 1833
Lines 110201 108772 -1429
Branches 20972 20514 -458
============================================
- Hits 53355 52338 -1017
+ Misses 49633 49252 -381
+ Partials 7213 7182 -31
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR builder completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/14357216988
a9af38e
to
e0d923c
Compare
|
Purpose
When there is a cache miss the value is added to the cache. But in a clustered environment many nodes may simultaneously read the initial value as null and then try to add the value. But at the time of adding the value, the first one to complete adding the value succeeds but other processes proceed to update the value instead of adding the value.
However while adding doesn't invalidate cache, updating does. But since if the new value is the same as the existing one, there's no need to update the value and then invalidate the cache. This behaviour causes unnecessary cache invalidations in clustered environments. This then leads to unnecessary db reads to retrieve the same value again and again.
Changes of this PR performs an equality check between the new value and the value in the cache and skips updating if the values are the same. This avoids unnecessary cache invalidations.
Related Issue/s
Dependent on