async fn try_shrink_db(&self) {
        // constant multipliers for cache threshold and shrink-to sizes
        // SHRINK_MULT = multiplier to the maximum size after shrinking, if shrink was triggered
        // MAX_MULT = multiplier to the max db size before triggering a shrink
        const SHRINK_MULT: f64 = 0.9;
        const MAX_MULT: f64 = 0.95;

        let db_sz = self.gs.cache.report() as f64;
        let max_sz = self.gs.config.cache_size_mebibytes as f64 * 1024f64 * 1024f64;
        log::info!(
            "reported cache size: {:.2}MiB ({:.2}%)",
            db_sz / 1024f64 / 1024f64,
            db_sz / max_sz * 100.0
        );
        self.gs.metrics.cache_size.set(db_sz as i64);
        self.gs.metrics.cache_max_size.set(max_sz as i64);

        // shrink database if reported size is above the maximum size reported in the config
        if db_sz > (max_sz * MAX_MULT) {
            log::warn!("database is over maximum size, shrinking...");
            let timer = utils::Timer::start();
            match self.gs.cache.shrink((max_sz * SHRINK_MULT) as u64).await {
                Ok(new_sz) => log::warn!("db shrinked to size {}B", new_sz),
                Err(_) => log::error!("problem shrinking database! hopefully there's more logs"),
            }
            log::info!("shrinking db took {}ms", timer.elapsed());
        }
    }
/// Shrinks the cache database if the reported size is above the maximum size in the config.
/// Will log if an error occurs (but not the specific error) and the time it took.
Shrinks the cache database if the reported size is above the maximum size in the config.
Will log if an error occurs (but not the specific error) and the time it took.
Shrinks the cache database if the reported size is above the maximum size in the config . Will log if an error occurs ( but not the specific error ) and the time it took .
async fn try_shrink_db(&self) {
        // constant multipliers for cache threshold and shrink-to sizes
        // SHRINK_MULT = multiplier to the maximum size after shrinking, if shrink was triggered
        // MAX_MULT = multiplier to the max db size before triggering a shrink
        const SHRINK_MULT: f64 = 0.9;
        const MAX_MULT: f64 = 0.95;
        let db_sz = self.gs.cache.report() as f64;
        let max_sz = self.gs.config.cache_size_mebibytes as f64 * 1024f64 * 1024f64;
        log::info!(
            "reported cache size: {:.2}MiB ({:.2}%)",
            db_sz / 1024f64 / 1024f64,
            db_sz / max_sz * 100.0
        );
        self.gs.metrics.cache_size.set(db_sz as i64);
        self.gs.metrics.cache_max_size.set(max_sz as i64);
        // shrink database if reported size is above the maximum size reported in the config
        if db_sz > (max_sz * MAX_MULT) {
            log::warn!("database is over maximum size, shrinking...");
            let timer = utils::Timer::start();
            match self.gs.cache.shrink((max_sz * SHRINK_MULT) as u64).await {
                Ok(new_sz) => log::warn!("db shrinked to size {}B", new_sz),
                Err(_) => log::error!("problem shrinking database! hopefully there's more logs"),
            }
            log::info!("shrinking db took {}ms", timer.elapsed());
        }
    }
async fn try_shrink_db ( & self ) { // constant multipliers for cache threshold and shrink-to sizes // SHRINK_MULT = multiplier to the maximum size after shrinking, if shrink was triggered // MAX_MULT = multiplier to the max db size before triggering a shrink const SHRINK_MULT : f64 = 0.9 ; const MAX_MULT : f64 = 0.95 ; let db_sz = self . gs . cache . report ( ) as f64 ; let max_sz = self . gs . config . cache_size_mebibytes as f64 * 1024f64 * 1024f64 ; log :: info ! ( " " db_sz 1024f64 1024f64 db_sz max_sz 100.0 ) ; self . gs . metrics . cache_size . set ( db_sz as i64 ) ; self . gs . metrics . cache_max_size . set ( max_sz as i64 ) ; // shrink database if reported size is above the maximum size reported in the config if db_sz > ( max_sz * MAX_MULT ) { log :: warn ! ( " " ) ; let timer = utils :: Timer :: start ( ) ; match self . gs . cache . shrink ( ( max_sz * SHRINK_MULT ) as u64 ) . await { Ok ( new_sz ) => log :: warn ! ( " " new_sz ) , Err ( _ ) => log :: error ! ( " " ) , } log :: info ! ( " " timer elapsed ( ) ) ; } }
Shrinks the cache database if the reported size is above the maximum size in the config.
Shrinks the cache database if the reported size is above the maximum size in the config .
&self