The tokio runtime handle that is used to block on evicted value's corresponding file deletion needs to be created in a context of a Tokio runtime.
If created in the eviction method itself it will silently panic with there is no reactor running, must be called from the context of a Tokio 1.x runtime, after which point no evictions will be attempted again (but everything will continue running). In turn this will eventually lead to cached file path already exists errors from #333, as the files are never cleaned up.
Arguably, it may be preferable to either skip or overwrite an existing path instead of erroring out, but I've left it for now as it may help us flush out some other bugs.
The tokio runtime handle that is used to block on evicted value's corresponding file deletion needs to be created in a context of a Tokio runtime.
If created in the eviction method itself it will silently panic with
there is no reactor running, must be called from the context of a Tokio 1.x runtime
, after which point no evictions will be attempted again (but everything will continue running). In turn this will eventually lead tocached file path already exists
errors from #333, as the files are never cleaned up.Arguably, it may be preferable to either skip or overwrite an existing path instead of erroring out, but I've left it for now as it may help us flush out some other bugs.
Co-incidentally, this revealed a design problem with the cache, namely after we full up the cache entirely, no further entries will be accepted, see here for more details: https://github.com/moka-rs/moka/issues/147#issuecomment-1162899784
Closes #333.