Module plain

Source
Expand description

A crate::plain::Cache stores all cached file in a single directory (there may also be a .kismet_temp subdirectory for temporary files), and periodically scans for evictions with a second chance strategy. This implementation does not scale up to more than a few hundred files per cache directory (a crate::sharded::Cache can go higher), but interoperates seamlessly with other file-based programs that store cache files in flat directories.

This module is useful for lower level usage; in most cases, the crate::Cache is more convenient and just as efficient. In particular, a crate::plain::Cache does not invoke std::fs::File::sync_all or std::fs::File::sync_data: the caller should sync files before letting Kismet persist them in a directory, if necessary.

The cache’s contents will grow past its stated capacity, but should rarely reach more than twice that capacity.

Structs§

Cache
A “plain” cache is a single directory of files. Given a capacity of k files, we will trigger a second chance maintance roughly every k / 3 (k / 6 in the long run, given the way PeriodicTrigger is implemented) insertions.