File tree Expand file tree Collapse file tree
src/paimon/common/io/cache Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,17 +70,32 @@ void LruCache::Invalidate(const std::shared_ptr<CacheKey>& key) {
7070
7171 auto it = lru_map_.find (key);
7272 if (it != lru_map_.end ()) {
73- current_weight_ -= GetWeight (it->second ->second );
73+ auto invalidated_key = it->second ->first ;
74+ auto invalidated_value = it->second ->second ;
75+ current_weight_ -= GetWeight (invalidated_value);
7476 lru_list_.erase (it->second );
7577 lru_map_.erase (it);
78+
79+ if (invalidated_value) {
80+ invalidated_value->OnEvict (invalidated_key);
81+ }
7682 }
7783}
7884
7985void LruCache::InvalidateAll () {
8086 std::lock_guard<std::mutex> lock (mutex_);
8187
82- lru_list_.clear ();
83- lru_map_.clear ();
88+ while (!lru_list_.empty ()) {
89+ auto invalidated_key = lru_list_.back ().first ;
90+ auto invalidated_value = lru_list_.back ().second ;
91+ current_weight_ -= GetWeight (invalidated_value);
92+ lru_map_.erase (invalidated_key);
93+ lru_list_.pop_back ();
94+
95+ if (invalidated_value) {
96+ invalidated_value->OnEvict (invalidated_key);
97+ }
98+ }
8499 current_weight_ = 0 ;
85100}
86101
You can’t perform that action at this time.
0 commit comments