Skip to main content

Cache

Trait Cache 

Source
pub trait Cache: Send + Sync {
    // Required methods
    fn last_build<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 ActionId,
    ) -> Pin<Box<dyn Future<Output = Option<BuildEvent>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn record<'life0, 'async_trait>(
        &'life0 mut self,
        event: BuildEvent,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn record_batch<'life0, 'async_trait>(
        &'life0 mut self,
        events: Vec<BuildEvent>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Persistent store for BuildEvents, keyed by ActionId.

The cache lets the planner compare current input hashes against the last recorded build, and lets the orchestrator persist new events as they fire.

Required Methods§

Source

fn last_build<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 ActionId, ) -> Pin<Box<dyn Future<Output = Option<BuildEvent>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Last recorded event for id, or None if the action has never run.

Source

fn record<'life0, 'async_trait>( &'life0 mut self, event: BuildEvent, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persist event. After success, Self::last_build for the event’s id must return this event.

Provided Methods§

Source

fn record_batch<'life0, 'async_trait>( &'life0 mut self, events: Vec<BuildEvent>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persist events atomically — either every event lands or none.

The orchestrator calls this at the end of each layer so a crash mid-batch doesn’t leave half the layer marked Success and the other half un-persisted (which would re-run those actions on the next sync, contradicting the cached Success).

The default implementation is a non-atomic loop over Self::record that suffices for in-memory backends; persistent backends (SQLite, etc.) should override with a transaction.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§