jaemk / cached

Rust cache structures and easy function memoization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache clear operation

9999years opened this issue · comments

Currently, there is no way to clear caches. For a DiskCache, this snippet does not seem to work (edit: the remove_expired_entries logic is broken, see #198 for a fix):

// This does not seem to work:
let lifespan = cache.cache_set_lifespan(0);
cache.remove_expired_entries();
match lifespan {
    Some(lifespan) => {
        cache.cache_set_lifespan(lifespan);
    }
    None => {
        // Uhh...
    }
}

Additionally, there's no method to remove the lifespan, so if there wasn't an expiration policy set before we called cache_set_lifespan there's no way to restore that state when we're done.