-
Notifications
You must be signed in to change notification settings - Fork 381
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
Check conflict key before updating expiration map. #154
Conversation
When setting keys, the check of the conflict key is happening after the expiration map is updated but the order of these two operations should be reversed. Also refactor the logic in this method for easier readability. Fixes #149
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.
Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jarifibrahim, @karlmcguire, and @martinmr)
store.go, line 164 at r1 (raw file):
if ok { // The item existed already. We need to check the conflict key and reject the // update if they do not match. The nwe update the expiration map.
"The ??? update?" -- fix this sentence.
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.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @jarifibrahim, @karlmcguire, and @manishrjain)
store.go, line 164 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
"The ??? update?" -- fix this sentence.
Done.
The update brings following changes from ristretto into badger ``` f66de99 Improve handling of updated items (hypermodeinc/ristretto#168) aec7994 Fix flaky TestCacheDel test (hypermodeinc/ristretto#169) a093fe6 Add benchmark plots to the project repo (hypermodeinc/ristretto#166) 49dc42c Add Anurag as codeowner (hypermodeinc/ristretto#158) 7a3f2d3 z: use MemHashString and xxhash.Sum64String (hypermodeinc/ristretto#153) 9c31bb2 Check conflict key before updating expiration map. (hypermodeinc/ristretto#154) 62cb731 Fix race condition in Cache.Clear (hypermodeinc/ristretto#133) 9af1934 Docs and whitespace changes for readability. (hypermodeinc/ristretto#143) dbc185e Add changelog. (hypermodeinc/ristretto#142) ff325ad Remove key from policy after TTL eviction (hypermodeinc/ristretto#130) 2dd5ff5 Use the require library in all the tests. (hypermodeinc/ristretto#128) 7c48141 Use require in all tests in cache_test.go (hypermodeinc/ristretto#127) 51e97ad Sets with TTL (hypermodeinc/ristretto#122) d3e7c37 Add benchmarks for math.rand and fastrand (hypermodeinc/ristretto#118) 593823e Integrate fixes from PR hypermodeinc/ristretto#91. (hypermodeinc/ristretto#126) 29b4dd7 Fix comments. (hypermodeinc/ristretto#123) ddf345c Removed workflows directory. (hypermodeinc/ristretto#124) eb104d0 Add martinmr to CODEOWNERS file. (hypermodeinc/ristretto#125) ```
The update brings following changes from ristretto into badger ``` f66de99 Improve handling of updated items (hypermodeinc/ristretto#168) aec7994 Fix flaky TestCacheDel test (hypermodeinc/ristretto#169) a093fe6 Add benchmark plots to the project repo (hypermodeinc/ristretto#166) 49dc42c Add Anurag as codeowner (hypermodeinc/ristretto#158) 7a3f2d3 z: use MemHashString and xxhash.Sum64String (hypermodeinc/ristretto#153) 9c31bb2 Check conflict key before updating expiration map. (hypermodeinc/ristretto#154) 62cb731 Fix race condition in Cache.Clear (hypermodeinc/ristretto#133) 9af1934 Docs and whitespace changes for readability. (hypermodeinc/ristretto#143) dbc185e Add changelog. (hypermodeinc/ristretto#142) ff325ad Remove key from policy after TTL eviction (hypermodeinc/ristretto#130) 2dd5ff5 Use the require library in all the tests. (hypermodeinc/ristretto#128) 7c48141 Use require in all tests in cache_test.go (hypermodeinc/ristretto#127) 51e97ad Sets with TTL (hypermodeinc/ristretto#122) d3e7c37 Add benchmarks for math.rand and fastrand (hypermodeinc/ristretto#118) 593823e Integrate fixes from PR hypermodeinc/ristretto#91. (hypermodeinc/ristretto#126) 29b4dd7 Fix comments. (hypermodeinc/ristretto#123) ddf345c Removed workflows directory. (hypermodeinc/ristretto#124) eb104d0 Add martinmr to CODEOWNERS file. (hypermodeinc/ristretto#125) ``` (cherry picked from commit 09dfa66)
The update brings following changes from ristretto into badger ``` f66de99 Improve handling of updated items (hypermodeinc/ristretto#168) aec7994 Fix flaky TestCacheDel test (hypermodeinc/ristretto#169) a093fe6 Add benchmark plots to the project repo (hypermodeinc/ristretto#166) 49dc42c Add Anurag as codeowner (hypermodeinc/ristretto#158) 7a3f2d3 z: use MemHashString and xxhash.Sum64String (hypermodeinc/ristretto#153) 9c31bb2 Check conflict key before updating expiration map. (hypermodeinc/ristretto#154) 62cb731 Fix race condition in Cache.Clear (hypermodeinc/ristretto#133) 9af1934 Docs and whitespace changes for readability. (hypermodeinc/ristretto#143) dbc185e Add changelog. (hypermodeinc/ristretto#142) ff325ad Remove key from policy after TTL eviction (hypermodeinc/ristretto#130) 2dd5ff5 Use the require library in all the tests. (hypermodeinc/ristretto#128) 7c48141 Use require in all tests in cache_test.go (hypermodeinc/ristretto#127) 51e97ad Sets with TTL (hypermodeinc/ristretto#122) d3e7c37 Add benchmarks for math.rand and fastrand (hypermodeinc/ristretto#118) 593823e Integrate fixes from PR hypermodeinc/ristretto#91. (hypermodeinc/ristretto#126) 29b4dd7 Fix comments. (hypermodeinc/ristretto#123) ddf345c Removed workflows directory. (hypermodeinc/ristretto#124) eb104d0 Add martinmr to CODEOWNERS file. (hypermodeinc/ristretto#125) ```
The update brings following changes from ristretto into badger ``` f66de99 Improve handling of updated items (hypermodeinc/ristretto#168) aec7994 Fix flaky TestCacheDel test (hypermodeinc/ristretto#169) a093fe6 Add benchmark plots to the project repo (hypermodeinc/ristretto#166) 49dc42c Add Anurag as codeowner (hypermodeinc/ristretto#158) 7a3f2d3 z: use MemHashString and xxhash.Sum64String (hypermodeinc/ristretto#153) 9c31bb2 Check conflict key before updating expiration map. (hypermodeinc/ristretto#154) 62cb731 Fix race condition in Cache.Clear (hypermodeinc/ristretto#133) 9af1934 Docs and whitespace changes for readability. (hypermodeinc/ristretto#143) dbc185e Add changelog. (hypermodeinc/ristretto#142) ff325ad Remove key from policy after TTL eviction (hypermodeinc/ristretto#130) 2dd5ff5 Use the require library in all the tests. (hypermodeinc/ristretto#128) 7c48141 Use require in all tests in cache_test.go (hypermodeinc/ristretto#127) 51e97ad Sets with TTL (hypermodeinc/ristretto#122) d3e7c37 Add benchmarks for math.rand and fastrand (hypermodeinc/ristretto#118) 593823e Integrate fixes from PR hypermodeinc/ristretto#91. (hypermodeinc/ristretto#126) 29b4dd7 Fix comments. (hypermodeinc/ristretto#123) ddf345c Removed workflows directory. (hypermodeinc/ristretto#124) eb104d0 Add martinmr to CODEOWNERS file. (hypermodeinc/ristretto#125) ```
When setting keys, the check of the conflict key is happening
after the expiration map is updated but the order of these two
operations should be reversed.
Also refactor the logic in this method for easier readability.
Fixes #149
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)