use std::thread;
use std::time::{Duration, Instant};
use super::cache::StoreCacheFlush;
pub struct StoreFlushBuilder;
pub struct StoreFlush;
const FLUSH_PERFORM_INTERVAL: Duration = Duration::from_secs(20);
impl StoreFlushBuilder {
pub fn new() -> StoreFlush {
StoreFlush {}
}
}
impl StoreFlush {
pub fn run(&self) {
info!("store flusher is now active");
loop {
thread::sleep(FLUSH_PERFORM_INTERVAL);
debug!("running a store flush...");
let flush_start = Instant::now();
Self::perform();
let flush_took = flush_start.elapsed();
info!(
"ran store flush (took {}s + {}ms)",
flush_took.as_secs(),
flush_took.subsec_millis()
);
}
}
fn perform() {
StoreCacheFlush::expire();
StoreCacheFlush::refresh();
}
}