fn evict_entries_fifo(&self, until_size: u64) -> Result<u64, CacheError> {
        // make sure we're working with the actual db size
        self.fetch_real_size()?;
        let mut sz = self.get_db_size()?;

        'evictor: loop {
            // create a queue of entries to evict based on the save time of the entry
            // this queue is automatically sorted based on the find_top_entries fn
            let queue = self.find_top_entries(256, |x, y| y.save_time.cmp(&x.save_time))?;

            // how did we get here? we'll break anyways but how
            if queue.is_empty() {
                log::debug!("how did we get here?");
                break;
            }

            // drop entries in the queue until we meet the minimum size
            // drops are considered fatal, so it'll be pushed up the stack if failed
            // if minimum size isn't met, then 'evictor loop will continue around, building a new queue
            for (key, entry) in queue {
                self.drop_entry(&key)?;
                sz -= entry.get_bytes_len();

                if sz <= until_size {
                    log::debug!("{} <= {}", sz, until_size);
                    break 'evictor;
                }
            }
        }

        self.db_size.store(sz, Ordering::SeqCst);
        Ok(sz)
    }
/// Eviction algorithm to evict the oldest entries in the database
Eviction algorithm to evict the oldest entries in the database
Eviction algorithm to evict the oldest entries in the database
fn evict_entries_fifo(&self, until_size: u64) -> Result<u64, CacheError> {
        // make sure we're working with the actual db size
        self.fetch_real_size()?;
        let mut sz = self.get_db_size()?;
        'evictor: loop {
            // create a queue of entries to evict based on the save time of the entry
            // this queue is automatically sorted based on the find_top_entries fn
            let queue = self.find_top_entries(256, |x, y| y.save_time.cmp(&x.save_time))?;
            // how did we get here? we'll break anyways but how
            if queue.is_empty() {
                log::debug!("how did we get here?");
                break;
            }
            // drop entries in the queue until we meet the minimum size
            // drops are considered fatal, so it'll be pushed up the stack if failed
            // if minimum size isn't met, then 'evictor loop will continue around, building a new queue
            for (key, entry) in queue {
                self.drop_entry(&key)?;
                sz -= entry.get_bytes_len();
                if sz <= until_size {
                    log::debug!("{} <= {}", sz, until_size);
                    break 'evictor;
                }
            }
        }
        self.db_size.store(sz, Ordering::SeqCst);
        Ok(sz)
    }
fn evict_entries_fifo ( & self , until_size : u64 ) -> Result < u64 , CacheError > { // make sure we're working with the actual db size self . fetch_real_size ( ) ? ; let mut sz = self . get_db_size ( ) ? ; ' evictor : loop { // create a queue of entries to evict based on the save time of the entry // this queue is automatically sorted based on the find_top_entries fn let queue = self . find_top_entries ( 256 , | x , y | y . save_time . cmp ( & x . save_time ) ) ? ; // how did we get here? we'll break anyways but how if queue . is_empty ( ) { log :: debug ! ( " " ) ; break ; } // drop entries in the queue until we meet the minimum size // drops are considered fatal, so it'll be pushed up the stack if failed // if minimum size isn't met, then 'evictor loop will continue around, building a new queue for ( key , entry ) in queue { self . drop_entry ( & key ) ? ; sz -= entry . get_bytes_len ( ) ; if sz <= until_size { log :: debug ! ( " " sz until_size ) ; break ' evictor ; } } } self . db_size . store ( sz , Ordering :: SeqCst ) ; Ok ( sz ) }
Eviction algorithm to evict the oldest entries in the database
Eviction algorithm to evict the oldest entries in the database
&self
until_size
u64