Open ndjuric-bit opened 10 months ago
Merging #383 (dd4212d) into main (58fe2d2) will increase coverage by
0.27%
. The diff coverage is82.75%
.:exclamation: Current head dd4212d differs from pull request most recent head 4c79098. Consider uploading reports for the commit 4c79098 to get more accurate results
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
@@ Coverage Diff @@
## main #383 +/- ##
==========================================
+ Coverage 88.66% 88.94% +0.27%
==========================================
Files 15 15
Lines 794 823 +29
==========================================
+ Hits 704 732 +28
Misses 76 76
- Partials 14 15 +1
Files | Coverage Δ | |
---|---|---|
bigcache.go | 93.18% <100.00%> (+0.21%) |
:arrow_up: |
shard.go | 90.97% <80.00%> (+0.47%) |
:arrow_up: |
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 58fe2d2...4c79098. Read the comment docs.
@ndjuric-bit Thanks for this. I think we need to solve issue with concurrent updates during setOrGet
with current implementation it's not locked so there might an override. I think this would be a rare case but possible so it needs to be documented. I also miss some tests how it behaves when error happens.
@janisz Is there something needed from my side more ?
Overview:
This pull request introduces a new feature to our cache implementation by adding the SetOrGet function. This function allows clients to efficiently set a cache entry if it doesn't exist or retrieve the existing value associated with a given key. It returns the actual value, a boolean indicating whether the entry was loaded from the cache or not, and any potential error.
Function Signature::
SetOrGet(key string, entry []byte) (actual []byte, loaded bool, err error)
Parameters:
Return Values:
Example:
Testing:
This pull request includes unit tests to ensure the correct behavior of the SetOrGet function. The tests cover various scenarios, including cache hits and cache misses.
Impact on Existing Code:
This change introduces a new function to cache system. Existing code that uses the cache may benefit from this function for efficient get-or-set operations, but it should not negatively impact the existing functionality. This change is designed to be backward compatible.
Documentation:
The function's usage has been documented, and code comments have been updated to reflect the introduction of the SetOrGet function.
Reviewer Instructions:
Please review the code changes and documentation to ensure that the SetOrGet function is correctly implemented and well-documented. Verify that the function behaves as expected, handles errors gracefully, and is a useful addition to our cache system. In case of hash collision behaviour of get function is held plus old data is deleted and new one is stored
Testing Instructions: Verify that the unit tests pass and consider adding additional test cases as needed to cover any edge cases.
Changelog: