pub struct QuotaManager { /* private fields */ }Expand description
Evicts least-recently-used files in a managed directory when asked to do so.
QuotaManager does not observe file system mutations! You have to tell it
about any files you create or delete in this directory. It stores this
information in a sqlite database file at a path of your choosing.
Implementations§
Source§impl QuotaManager
impl QuotaManager
Sourcepub fn new(root_path: &Path, db_path: &Path) -> Result<Self, String>
pub fn new(root_path: &Path, db_path: &Path) -> Result<Self, String>
Create an instance for the managed directory given by root_path.
Uses the database at db_path to store information about the files
under this directory, and creates it if it doesn’t exist yet,
prepopulating it with information about the current files in the
managed directory.
Both root_path and the parent directory of db_path must already exist.
Sourcepub fn notifier(&self) -> QuotaManagerNotifier
pub fn notifier(&self) -> QuotaManagerNotifier
Returns a new QuotaManagerNotifier. This is how you tell this
QuotaManager about file creations / accesses
Sourcepub async fn finish(self)
pub async fn finish(self)
Stops the background task that does the evictions, and waits for any currently-running eviction to finish.
Sourcepub fn set_max_total_size(&self, max_size_bytes: Option<u64>)
pub fn set_max_total_size(&self, max_size_bytes: Option<u64>)
Change the desired maximum total size of the managed directory, in bytes.
Respected during the next eviction.
Sourcepub fn set_max_age(&self, max_age_seconds: Option<u64>)
pub fn set_max_age(&self, max_age_seconds: Option<u64>)
Change the desired maximum age of tracked files in the managed directory, in seconds.
Respected during the next eviction.