Skip to content

Commit

Permalink
Fix an issue that the last modified time might be get a little too early
Browse files Browse the repository at this point in the history
if eviction listener is enabled
  • Loading branch information
tatsuya6502 committed Sep 9, 2023
1 parent eddec37 commit ffb71de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/future/base_cache.rs
Expand Up @@ -479,7 +479,6 @@ where
) -> (WriteOp<K, V>, Instant) {
self.retry_interrupted_ops().await;

let ts = self.current_time_from_expiration_clock();
let weight = self.inner.weigh(&key, &value);
let op_cnt1 = Arc::new(AtomicU8::new(0));
let op_cnt2 = Arc::clone(&op_cnt1);
Expand All @@ -494,6 +493,8 @@ where
None
};

let ts = self.current_time_from_expiration_clock();

// Since the cache (cht::SegmentedHashMap) employs optimistic locking
// strategy, insert_with_or_modify() may get an insert/modify operation
// conflicted with other concurrent hash table operations. In that case, it
Expand Down
3 changes: 2 additions & 1 deletion src/sync_base/base_cache.rs
Expand Up @@ -480,7 +480,6 @@ where
hash: u64,
value: V,
) -> (WriteOp<K, V>, Instant) {
let ts = self.current_time_from_expiration_clock();
let weight = self.inner.weigh(&key, &value);
let op_cnt1 = Rc::new(AtomicU8::new(0));
let op_cnt2 = Rc::clone(&op_cnt1);
Expand All @@ -491,6 +490,8 @@ where
let kl = self.maybe_key_lock(&key);
let _klg = &kl.as_ref().map(|kl| kl.lock());

let ts = self.current_time_from_expiration_clock();

// Since the cache (cht::SegmentedHashMap) employs optimistic locking
// strategy, insert_with_or_modify() may get an insert/modify operation
// conflicted with other concurrent hash table operations. In that case, it
Expand Down

0 comments on commit ffb71de

Please sign in to comment.