CacheBackend

Trait CacheBackend 

Source
pub trait CacheBackend: Send + Sync {
    // Required methods
    fn check<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        task: &'life1 IRTask,
        digest: &'life2 str,
        policy: CachePolicy,
    ) -> Pin<Box<dyn Future<Output = BackendResult<CacheLookupResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn store<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        task: &'life1 IRTask,
        digest: &'life2 str,
        entry: &'life3 CacheEntry,
        policy: CachePolicy,
    ) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn restore_outputs<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        task: &'life1 IRTask,
        digest: &'life2 str,
        workspace: &'life3 Path,
    ) -> Pin<Box<dyn Future<Output = BackendResult<Vec<CacheOutput>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_logs<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        task: &'life1 IRTask,
        digest: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = BackendResult<(Option<String>, Option<String>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn name(&self) -> &'static str;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Cache backend trait for pluggable cache implementations

Implementations must be thread-safe (Send + Sync) for concurrent task execution.

Required Methods§

Source

fn check<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, task: &'life1 IRTask, digest: &'life2 str, policy: CachePolicy, ) -> Pin<Box<dyn Future<Output = BackendResult<CacheLookupResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if a cached result exists for the given task and digest

§Arguments
  • task - The IR task definition
  • digest - Pre-computed digest (cache key)
  • policy - Effective cache policy (may be overridden globally)
§Returns

CacheLookupResult indicating whether a cache hit was found

Source

fn store<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, task: &'life1 IRTask, digest: &'life2 str, entry: &'life3 CacheEntry, policy: CachePolicy, ) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Store a task execution result in the cache

§Arguments
  • task - The IR task definition
  • digest - Pre-computed digest (cache key)
  • entry - The execution result to store
  • policy - Effective cache policy
§Errors

Returns error if storage fails (but callers should handle gracefully)

Source

fn restore_outputs<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, task: &'life1 IRTask, digest: &'life2 str, workspace: &'life3 Path, ) -> Pin<Box<dyn Future<Output = BackendResult<Vec<CacheOutput>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Restore output artifacts from cache to the workspace

§Arguments
  • task - The IR task definition
  • digest - Pre-computed digest (cache key)
  • workspace - Directory to restore outputs to
§Errors

Returns error if restoration fails

Source

fn get_logs<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, task: &'life1 IRTask, digest: &'life2 str, ) -> Pin<Box<dyn Future<Output = BackendResult<(Option<String>, Option<String>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get cached stdout/stderr logs

§Arguments
  • task - The IR task definition
  • digest - Pre-computed digest (cache key)
§Returns

Tuple of (stdout, stderr) if available

Source

fn name(&self) -> &'static str

Get the backend name for logging/metrics

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the backend is available/connected

Implementors§