Skip to main content

IssueCache

Struct IssueCache 

Source
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

Source

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.

Source

pub fn disabled() -> Self

A cache that never reads or writes anything.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Debug for IssueCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more