@@ -532,7 +532,7 @@ impl CacheEvictionManager {
532532 let mut total_size_removed = 0 ;
533533 let mut total_delete_skipped = 0 ;
534534
535- let expired_items = self . collect_stats_and_candidates_to_evict ( & store) . await ?;
535+ let expired_items = self . collect_stats_and_expired_keys ( & store) . await ?;
536536 let expired_len = expired_items. len ( ) ;
537537
538538 if expired_len > 0 {
@@ -559,42 +559,40 @@ impl CacheEvictionManager {
559559 } ) )
560560 }
561561
562- async fn collect_stats_and_candidates_to_evict (
562+ async fn collect_stats_and_expired_keys (
563563 & self ,
564564 store : & Arc < RocksStore > ,
565565 ) -> Result < KeysVector , CubeError > {
566- let ( to_delete , stats_total_keys, stats_total_raw_size) = store
566+ let ( expired , stats_total_keys, stats_total_raw_size) = store
567567 . read_operation_out_of_queue ( move |db_ref| {
568568 let mut stats_total_keys: u32 = 0 ;
569569 let mut stats_total_raw_size: u64 = 0 ;
570570
571- let mut result = KeysVector :: new ( ) ;
572571 let now = Utc :: now ( ) ;
573572 let cache_schema = CacheItemRocksTable :: new ( db_ref. clone ( ) ) ;
574573
574+ let mut expired = KeysVector :: new ( ) ;
575+
575576 for item in cache_schema. scan_index_values ( & CacheItemRocksIndex :: ByPath ) ? {
576577 let item = item?;
577578
578- stats_total_keys += 1 ;
579-
580579 let row_size = if let Some ( extended) = item. extended {
581- stats_total_raw_size += extended. raw_size as u64 ;
582580 extended. raw_size
583581 } else {
584- // count keys without size as 1
585- stats_total_raw_size += 1_u64 ;
586-
587- 0
582+ CACHE_ITEM_SIZE_WITHOUT_VALUE
588583 } ;
589584
585+ stats_total_keys += 1 ;
586+ stats_total_raw_size += row_size as u64 ;
587+
590588 if let Some ( ttl) = item. ttl {
591589 if ttl < now {
592- result . push ( ( item. row_id , row_size) ) ;
590+ expired . push ( ( item. row_id , row_size) ) ;
593591 }
594592 }
595593 }
596594
597- Ok ( ( result , stats_total_keys, stats_total_raw_size) )
595+ Ok ( ( expired , stats_total_keys, stats_total_raw_size) )
598596 } )
599597 . await ?;
600598
@@ -603,7 +601,7 @@ impl CacheEvictionManager {
603601 self . stats_total_raw_size
604602 . store ( stats_total_raw_size, Ordering :: Release ) ;
605603
606- Ok ( to_delete )
604+ Ok ( expired )
607605 }
608606
609607 async fn collect_allkeys_to_evict (
0 commit comments