pub struct Cache { /* private fields */ }Expand description
A store rooted at a project.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn open(root: &Path, opts: Options) -> Option<Self>
pub fn open(root: &Path, opts: Options) -> Option<Self>
None when the caller turned caching off, or when this build cannot identify
itself well enough to be sure an entry is its own.
Sourcepub fn mode(&self) -> Mode
pub fn mode(&self) -> Mode
The grain this store was opened with. A caller that decides between a per-module walk and a whole-run lookup asks the store rather than re-reading the flags, so the two cannot disagree.
Sourcepub fn lookup_all(
&self,
keys: &[Key],
run: &Key,
files: usize,
) -> Vec<Option<Module>>
pub fn lookup_all( &self, keys: &[Key], run: &Key, files: usize, ) -> Vec<Option<Module>>
What each file in the walk reported last time; None where it has to be checked.
Under WholeRun this is all-or-nothing by construction: one entry covers the walk,
so a single changed input means every module is checked.
Sourcepub fn lookup(&self, key: &Key) -> Option<Module>
pub fn lookup(&self, key: &Key) -> Option<Module>
What the module reported last time, if every input and probe still matches.
Sourcepub fn store_module(
&self,
key: &Key,
file: &Path,
extra_inputs: &[PathBuf],
dirs: &[PathBuf],
module: &Module,
)
pub fn store_module( &self, key: &Key, file: &Path, extra_inputs: &[PathBuf], dirs: &[PathBuf], module: &Module, )
Record what one module reported. Best-effort: a store that cannot be written leaves the next run to do the work again, which is slow rather than wrong.
Sourcepub fn store_run(
&self,
key: &Key,
files: &[PathBuf],
extra_inputs: &[PathBuf],
dirs: &[PathBuf],
modules: &[Module],
)
pub fn store_run( &self, key: &Key, files: &[PathBuf], extra_inputs: &[PathBuf], dirs: &[PathBuf], modules: &[Module], )
Record the whole walk as one entry. Its inputs are the union of every module’s, so any edit anywhere misses — which is the behaviour this mode is chosen for.
Sourcepub fn sweep(&self, keep: &[Key], files: usize)
pub fn sweep(&self, keep: &[Key], files: usize)
Drop entries this run did not use, once the store has outgrown what the project warrants.
Nothing else removes an entry. The key covers the paths as written, the lint
selection and the working directory, so every distinct way of invoking the check
leaves a full set of module entries behind — a lint flag tried once doubles the store
permanently, and a deleted module’s entry is never read again. htl check sees the
whole graph in one process, which is what lets this be exact about the orphans rather
than sampling the way ccache has to.
Two passes. Entries whose recorded inputs have all gone describe modules that no longer exist, and go first. If the store is still over, the oldest go until it fits.
This uses mtimes, and #3’s rule against them still holds. That rule is about invalidation, where trusting a timestamp means replaying a stale result and reporting something untrue. Dropping an entry that was still good costs the check it would have skipped and nothing else. The two questions deserve different tools.
“Oldest” is least recently used: a hit touches its entry, which is what makes the two differ. Without that it would mean least recently written, and the shape run most often — written first — would age out while a shape tried once survived.
Auto Trait Implementations§
impl !Freeze for Cache
impl !RefUnwindSafe for Cache
impl !Sync for Cache
impl Send for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more