pub struct IssueCache { /* private fields */ }Expand description
The GitHub fetch cache shared by route and verify-decision.
Also counts how many items a run reused and the age of the oldest, so the
CLI can say so (reuse_note) — stale input is never
silent.
Implementations§
Source§impl IssueCache
impl IssueCache
Sourcepub fn new(dir: PathBuf, ttl: Duration, refresh: bool) -> Self
pub fn new(dir: PathBuf, ttl: Duration, refresh: bool) -> Self
A cache rooted at dir (the directory holding <owner>/<repo>/),
reusing entries younger than ttl. refresh re-fetches everything
while still writing the fresh copies back.
Sourcepub fn from_env_with(
env: &impl EnvSource,
base: Option<PathBuf>,
account: Option<&str>,
refresh: bool,
) -> Self
pub fn from_env_with( env: &impl EnvSource, base: Option<PathBuf>, account: Option<&str>, refresh: bool, ) -> Self
The cache configured from env (in production, the SettingsEnv the
command already loaded), rooted under base (dirs::cache_dir()).
account is the account_scope digest of the gh login the fetches will
run as. Without one (gh could not say who it is) the cache is
disabled, since an entry it wrote could later be served to another
login. With no base directory the cache is disabled too. A zero TTL
disables reads and writes but keeps the root, so the sweep still
clears what an earlier run cached.
Sourcepub fn prune_expired(&self)
pub fn prune_expired(&self)
Deletes every expired entry, and every temp file a crashed write orphaned. Best-effort, like everything else here; blocking, so run it on the same blocking thread as the fetch.
Age is the file’s mtime, which a write sets to when it stored the entry, so the sweep never reads or parses an entry. It covers every account’s entries, and with a zero TTL it removes them all.
Sourcepub fn usage(&self) -> Option<CacheUsage>
pub fn usage(&self) -> Option<CacheUsage>
What this run reused, for the machine-readable output, or None when
it reused nothing. The stderr reuse_note is the
human’s copy of the same facts; a script reading only stdout needs this.
Sourcepub fn reuse_note(&self) -> Option<String>
pub fn reuse_note(&self) -> Option<String>
A one-line note for stderr when this run reused cached items, naming how many, the oldest’s age, and how to bypass the cache.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for IssueCache
impl RefUnwindSafe for IssueCache
impl Send for IssueCache
impl Sync for IssueCache
impl Unpin for IssueCache
impl UnsafeUnpin for IssueCache
impl UnwindSafe for IssueCache
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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