Skip to main content

Cache

Struct Cache 

Source
pub struct Cache<FsT: Fs, KeyT: Key, GetStrategyT: GetStrategy> { /* private fields */ }
Expand description

Manage a directory of downloaded, extracted artifacts. Coordinate fetching of these artifacts, and removing them when they are no longer in use and the amount of space used by the directory has grown too large.

Implementations§

Source§

impl<FsT: Fs, KeyT: Key, GetStrategyT: GetStrategy> Cache<FsT, KeyT, GetStrategyT>

Source

pub fn new( fs: FsT, root: RootBuf<CacheDir>, size: CacheSize, log: Logger, log_initial_message_at_info: bool, ) -> Result<(Self, TempFileFactory<FsT>)>

Create a new Cache rooted at root. The directory root and all necessary ancestors will be created, along with {root}/removing and {root}/{kind}/sha256. Any pre-existing entries in {root}/removing and {root}/{kind}/sha256 will be removed. That implies that the Cache doesn’t currently keep data stored across invocations.

bytes_used_target is the goal on-disk size for the cache. The cache will periodically grow larger than this size, but then shrink back down to this size. Ideally, the cache would use this as a hard upper bound, but that’s not how it currently works.

Source

pub fn get_artifact(&mut self, key: KeyT, jid: JobId) -> GetArtifact

Attempt to fetch artifact from the cache. See GetArtifact for the meaning of the return values.

Source

pub fn got_artifact_failure(&mut self, key: &KeyT) -> Vec<JobId>

Notify the cache that an artifact fetch has failed. The returned vector lists the jobs that are affected and that need to be canceled.

Source

pub fn got_artifact_success( &mut self, key: &KeyT, artifact: GotArtifact<FsT>, ) -> Result<Vec<JobId>, (Error, Vec<JobId>)>

Notify the cache that an artifact fetch has successfully completed. The returned vector lists the jobs that are affected, and the path they can use to access the artifact.

Source

pub fn try_increment_ref_count(&mut self, key: &KeyT) -> Option<u64>

Assuming that a reference count is already is already held for the artifact, increment it by one and return the size of the artifact. If no reference count is already held, return None.

Source

pub fn try_get_size(&mut self, key: &KeyT) -> Option<u64>

Assuming that a reference count is already is already held for the artifact, return the size of the artifact, otherwise return None.

Source

pub fn decrement_ref_count(&mut self, key: &KeyT)

Notify the cache that a reference to an artifact is no longer needed.

Source

pub fn getter_disconnected(&mut self, getter: GetStrategyT::Getter)

Source

pub fn root(&self) -> &Root<CacheDir>

Source

pub fn cache_path(&self, key: &KeyT) -> RootBuf<EntryPath>

Return the directory path for the artifact referenced by digest.

Auto Trait Implementations§

§

impl<FsT, KeyT, GetStrategyT> Freeze for Cache<FsT, KeyT, GetStrategyT>
where FsT: Freeze, Map<KeyT, GetStrategyT>: Freeze, Heap<Map<KeyT, GetStrategyT>>: Freeze, <FsT as Fs>::FileLock: Freeze,

§

impl<FsT, KeyT, GetStrategyT> RefUnwindSafe for Cache<FsT, KeyT, GetStrategyT>
where FsT: RefUnwindSafe, Map<KeyT, GetStrategyT>: RefUnwindSafe, Heap<Map<KeyT, GetStrategyT>>: RefUnwindSafe, <FsT as Fs>::FileLock: RefUnwindSafe,

§

impl<FsT, KeyT, GetStrategyT> Send for Cache<FsT, KeyT, GetStrategyT>
where FsT: Send, Map<KeyT, GetStrategyT>: Send, Heap<Map<KeyT, GetStrategyT>>: Send, <FsT as Fs>::FileLock: Send,

§

impl<FsT, KeyT, GetStrategyT> Sync for Cache<FsT, KeyT, GetStrategyT>
where FsT: Sync, Map<KeyT, GetStrategyT>: Sync, Heap<Map<KeyT, GetStrategyT>>: Sync, <FsT as Fs>::FileLock: Sync,

§

impl<FsT, KeyT, GetStrategyT> Unpin for Cache<FsT, KeyT, GetStrategyT>
where FsT: Unpin, Map<KeyT, GetStrategyT>: Unpin, Heap<Map<KeyT, GetStrategyT>>: Unpin, <FsT as Fs>::FileLock: Unpin,

§

impl<FsT, KeyT, GetStrategyT> UnsafeUnpin for Cache<FsT, KeyT, GetStrategyT>
where FsT: UnsafeUnpin, Map<KeyT, GetStrategyT>: UnsafeUnpin, Heap<Map<KeyT, GetStrategyT>>: UnsafeUnpin, <FsT as Fs>::FileLock: UnsafeUnpin,

§

impl<FsT, KeyT, GetStrategyT> UnwindSafe for Cache<FsT, KeyT, GetStrategyT>
where FsT: UnwindSafe, Map<KeyT, GetStrategyT>: UnwindSafe, Heap<Map<KeyT, GetStrategyT>>: UnwindSafe, <FsT as Fs>::FileLock: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

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, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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