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):
- Implement
CacheBackendwith the new storage format - Add a variant to
BackendKind - Update
ResultCache::storeto select the new backend
Required Methods§
Sourcefn kind(&self) -> BackendKind
fn kind(&self) -> BackendKind
What kind of backend this is.
Sourcefn execute(&self, op: CacheOp) -> Result<String, CacheError>
fn execute(&self, op: CacheOp) -> Result<String, CacheError>
Execute an operation on the cached data.
Sourcefn stats(&self) -> Result<CacheStats, CacheError>
fn stats(&self) -> Result<CacheStats, CacheError>
Statistics about the cached data.
Sourcefn preview(&self, max_lines: usize) -> Result<String, CacheError>
fn preview(&self, max_lines: usize) -> Result<String, CacheError>
A short preview of the data (first N lines/rows).
Sourcefn disk_bytes(&self) -> Result<u64, CacheError>
fn disk_bytes(&self) -> Result<u64, CacheError>
Size on disk in bytes.