pub struct DiskCache { /* private fields */ }Expand description
The local disk tier.
Implementations§
Source§impl DiskCache
impl DiskCache
Sourcepub fn list(&self) -> Vec<Listed>
pub fn list(&self) -> Vec<Listed>
Every file under <root>/v2, classified. Files that vanish while
listing are skipped.
Sourcepub fn check_file(
path: &Path,
key: &QueryKey,
) -> Result<(Meta, Vec<u8>), Problem>
pub fn check_file( path: &Path, key: &QueryKey, ) -> Result<(Meta, Vec<u8>), Problem>
Fully checks the entry file at path for key: integrity (header,
key, hash) and the shape of the reply for its command.
§Errors
The first problem found.
Sourcepub fn summarize(&self) -> Summary
pub fn summarize(&self) -> Summary
Summarizes the cache: entries and bytes by command, unknown
answers and their recorded effort, and files that are not valid
entries. Reads every entry; removes nothing.
Sourcepub fn verify(&self, remove: bool) -> VerifyReport
pub fn verify(&self, remove: bool) -> VerifyReport
Checks every file under <root>/v2. With remove, deletes each bad
one. Temporary files younger than STALE_TEMP are skipped.
Sourcepub fn gc(&self, max_bytes: u64) -> GcReport
pub fn gc(&self, max_bytes: u64) -> GcReport
Evicts the least recently used entries until entry files take at
most max_bytes, and removes temporary files older than
STALE_TEMP. “Used” is the later of a file’s access time (which
the daemon refreshes on hits) and its modification time.
Source§impl DiskCache
impl DiskCache
Sourcepub fn entries_dir(&self) -> PathBuf
pub fn entries_dir(&self) -> PathBuf
The directory holding every entry, <root>/v2.
Sourcepub fn entry_path(&self, key: &QueryKey) -> PathBuf
pub fn entry_path(&self, key: &QueryKey) -> PathBuf
The path of key’s entry file.
Sourcepub fn get(&self, key: &QueryKey) -> Option<(Meta, Vec<u8>)>
pub fn get(&self, key: &QueryKey) -> Option<(Meta, Vec<u8>)>
The reply stored for key, if there is a valid entry.
Sourcepub fn get_stamped(&self, key: &QueryKey) -> Option<Stored>
pub fn get_stamped(&self, key: &QueryKey) -> Option<Stored>
The entry stored for key, if valid, with the stamp of the file it
was read from. A hit refreshes the file’s access time (at most once
per TOUCH_INTERVAL). An invalid entry file is removed.
Sourcepub fn stamp_for_hit(&self, key: &QueryKey) -> Option<FileStamp>
pub fn stamp_for_hit(&self, key: &QueryKey) -> Option<FileStamp>
The stamp of key’s entry file as it is now, if it is a file. The
caller is about to serve this entry from memory, so the access time
is refreshed if it is older than TOUCH_INTERVAL, for gc.
Sourcepub fn contains(&self, key: &QueryKey) -> bool
pub fn contains(&self, key: &QueryKey) -> bool
Whether an entry file exists for key (valid or not).
Sourcepub fn put(
&self,
key: &QueryKey,
reply: &[u8],
command: &str,
solver: &str,
provenance: &str,
effort: Option<&Effort>,
) -> Result<()>
pub fn put( &self, key: &QueryKey, reply: &[u8], command: &str, solver: &str, provenance: &str, effort: Option<&Effort>, ) -> Result<()>
Stores reply for key. Existing entries are left alone: content
addressing means they hold the same answer.
§Errors
I/O errors creating or writing the entry.
Sourcepub fn put_stamped(
&self,
key: &QueryKey,
reply: &[u8],
command: &str,
solver: &str,
provenance: &str,
effort: Option<&Effort>,
) -> Result<PutOutcome>
pub fn put_stamped( &self, key: &QueryKey, reply: &[u8], command: &str, solver: &str, provenance: &str, effort: Option<&Effort>, ) -> Result<PutOutcome>
DiskCache::put, reporting whether the entry was written and, if
so, the stamp of the file now at the entry’s path.
§Errors
I/O errors creating or writing the entry.
Sourcepub fn put_scoped(
&self,
key: &QueryKey,
reply: &[u8],
command: &str,
context: &StoreContext<'_>,
effort: Option<&Effort>,
) -> Result<PutOutcome>
pub fn put_scoped( &self, key: &QueryKey, reply: &[u8], command: &str, context: &StoreContext<'_>, effort: Option<&Effort>, ) -> Result<PutOutcome>
Stores an entry with explicit provenance and verification namespace.
§Errors
I/O errors creating or writing the entry.