Skip to main content

CacheBackend

Trait CacheBackend 

Source
pub trait CacheBackend: Send + Sync {
    // Required methods
    fn kind(&self) -> BackendKind;
    fn execute(&self, op: CacheOp) -> Result<String, CacheError>;
    fn stats(&self) -> Result<CacheStats, CacheError>;
    fn preview(&self, max_lines: usize) -> Result<String, CacheError>;
    fn disk_bytes(&self) -> Result<u64, CacheError>;
}
Expand description

A backend that stores and operates on one cached result.

Implementations are created by ResultCache::store and live for the lifetime of the cache entry. Each backend owns its backing storage (file, buffer, etc.).

§Extending

To add a new backend (e.g. Parquet/Arrow for tabular data):

  1. Implement CacheBackend with the new storage format
  2. Add a variant to BackendKind
  3. Update ResultCache::store to select the new backend

Required Methods§

Source

fn kind(&self) -> BackendKind

What kind of backend this is.

Source

fn execute(&self, op: CacheOp) -> Result<String, CacheError>

Execute an operation on the cached data.

Source

fn stats(&self) -> Result<CacheStats, CacheError>

Statistics about the cached data.

Source

fn preview(&self, max_lines: usize) -> Result<String, CacheError>

A short preview of the data (first N lines/rows).

Source

fn disk_bytes(&self) -> Result<u64, CacheError>

Size on disk in bytes.

Implementors§