Skip to content

Commit

Permalink
existing key branch
Browse files Browse the repository at this point in the history
Signed-off-by: hjiang <[email protected]>
  • Loading branch information
dentiny committed Nov 27, 2024
1 parent 3ab6c0e commit b7f44cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ray/util/shared_lru.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ class SharedLruCache final {
if (iter != cache_.end()) {
lru_list_.splice(lru_list_.begin(), lru_list_, iter->second.lru_iterator);
iter->second.value = std::move(value);
} else {
lru_list_.emplace_front(key);
Entry new_entry{std::move(value), lru_list_.begin()};
cache_[std::move(key)] = std::move(new_entry);
return;
}

lru_list_.emplace_front(key);
Entry new_entry{std::move(value), lru_list_.begin()};
cache_[std::move(key)] = std::move(new_entry);

if (max_entries_ > 0 && lru_list_.size() > max_entries_) {
const auto &stale_key = lru_list_.back();
cache_.erase(stale_key);
Expand Down

0 comments on commit b7f44cd

Please sign in to comment.