fn flush_remove_from_cache(
        &self,
        removes: Vec<Pubkey>,
        current_age: Age,
        startup: bool,
        randomly_evicted: bool,
        exceeds_budget: bool,
    ) -> bool {
        let mut completed_scan = true;
        if removes.is_empty() {
            return completed_scan; // completed, don't need to get lock or do other work
        }

        let ranges = self.cache_ranges_held.read().unwrap().clone();

        let mut removed = 0;
        // consider chunking these so we don't hold the write lock too long
        let mut map = self.map().write().unwrap();
        for k in removes {
            if let Entry::Occupied(occupied) = map.entry(k) {
                let v = occupied.get();
                if Arc::strong_count(v) > 1 {
                    // someone is holding the value arc's ref count and could modify it, so do not remove this from in-mem cache
                    completed_scan = false;
                    continue;
                }

                if v.dirty()
                    || (!randomly_evicted
                        && !self.should_remove_from_mem(
                            current_age,
                            v,
                            startup,
                            false,
                            exceeds_budget,
                        ))
                {
                    // marked dirty or bumped in age after we looked above
                    // these will be handled in later passes
                    // but, at startup, everything is ready to age out if it isn't dirty
                    continue;
                }

                if ranges.iter().any(|range| range.contains(&k)) {
                    // this item is held in mem by range, so don't remove
                    completed_scan = false;
                    continue;
                }

                if self.get_stop_flush() {
                    return false; // did NOT complete, told to stop
                }

                // all conditions for removing succeeded, so really remove item from in-mem cache
                removed += 1;
                occupied.remove();
            }
        }
        if map.is_empty() {
            map.shrink_to_fit();
        }
        drop(map);
        self.stats()
            .insert_or_delete_mem_count(false, self.bin, removed);
        Self::update_stat(&self.stats().flush_entries_removed_from_mem, removed as u64);

        completed_scan
    }
// remove keys in 'removes' from in-mem cache due to age
// return true if the removal was completed
remove keys in 'removes' from in-mem cache due to age
return true if the removal was completed
remove keys in ' removes ' from in - mem cache due to age return true if the removal was completed
fn flush_remove_from_cache(
        &self,
        removes: Vec<Pubkey>,
        current_age: Age,
        startup: bool,
        randomly_evicted: bool,
        exceeds_budget: bool,
    ) -> bool {
        let mut completed_scan = true;
        if removes.is_empty() {
            return completed_scan; // completed, don't need to get lock or do other work
        }
        let ranges = self.cache_ranges_held.read().unwrap().clone();
        let mut removed = 0;
        // consider chunking these so we don't hold the write lock too long
        let mut map = self.map().write().unwrap();
        for k in removes {
            if let Entry::Occupied(occupied) = map.entry(k) {
                let v = occupied.get();
                if Arc::strong_count(v) > 1 {
                    // someone is holding the value arc's ref count and could modify it, so do not remove this from in-mem cache
                    completed_scan = false;
                    continue;
                }
                if v.dirty()
                    || (!randomly_evicted
                        && !self.should_remove_from_mem(
                            current_age,
                            v,
                            startup,
                            false,
                            exceeds_budget,
                        ))
                {
                    // marked dirty or bumped in age after we looked above
                    // these will be handled in later passes
                    // but, at startup, everything is ready to age out if it isn't dirty
                    continue;
                }
                if ranges.iter().any(|range| range.contains(&k)) {
                    // this item is held in mem by range, so don't remove
                    completed_scan = false;
                    continue;
                }
                if self.get_stop_flush() {
                    return false; // did NOT complete, told to stop
                }
                // all conditions for removing succeeded, so really remove item from in-mem cache
                removed += 1;
                occupied.remove();
            }
        }
        if map.is_empty() {
            map.shrink_to_fit();
        }
        drop(map);
        self.stats()
            .insert_or_delete_mem_count(false, self.bin, removed);
        Self::update_stat(&self.stats().flush_entries_removed_from_mem, removed as u64);
        completed_scan
    }
fn flush_remove_from_cache ( & self , removes : Vec < Pubkey > , current_age : Age , startup : bool , randomly_evicted : bool , exceeds_budget : bool , ) -> bool { let mut completed_scan = true ; if removes . is_empty ( ) { return completed_scan ; // completed, don't need to get lock or do other work } let ranges = self . cache_ranges_held . read ( ) . unwrap ( ) . clone ( ) ; let mut removed = 0 ; // consider chunking these so we don't hold the write lock too long let mut map = self . map ( ) . write ( ) . unwrap ( ) ; for k in removes { if let Entry :: Occupied ( occupied ) = map . entry ( k ) { let v = occupied . get ( ) ; if Arc :: strong_count ( v ) > 1 { // someone is holding the value arc's ref count and could modify it, so do not remove this from in-mem cache completed_scan = false ; continue ; } if v . dirty ( ) || ( ! randomly_evicted && ! self . should_remove_from_mem ( current_age , v , startup , false , exceeds_budget , ) ) { // marked dirty or bumped in age after we looked above // these will be handled in later passes // but, at startup, everything is ready to age out if it isn't dirty continue ; } if ranges . iter ( ) . any ( | range | range . contains ( & k ) ) { // this item is held in mem by range, so don't remove completed_scan = false ; continue ; } if self . get_stop_flush ( ) { return false ; // did NOT complete, told to stop } // all conditions for removing succeeded, so really remove item from in-mem cache removed += 1 ; occupied . remove ( ) ; } } if map . is_empty ( ) { map . shrink_to_fit ( ) ; } drop ( map ) ; self . stats ( ) . insert_or_delete_mem_count ( false , self . bin , removed ) ; Self :: update_stat ( & self . stats ( ) . flush_entries_removed_from_mem , removed as u64 ) ; completed_scan }
remove keys in 'removes' from in-mem cache due to age
return true if the removal was completed
remove keys in ' removes ' from in - mem cache due to age return true if the removal was completed
&self
removes
Vec<Pubkey>
current_age
Age
startup
bool
randomly_evicted
bool
exceeds_budget
bool