Skip to main content

CachePager

Trait CachePager 

Source
pub trait CachePager: Send {
    // Required methods
    fn meta(&self) -> CacheMeta;
    fn pause(&mut self) -> Result<()>;
    fn resume(&mut self) -> Result<()>;
    fn occupied_pages(&self) -> Vec<u32>;
    fn logical_seqs(&self) -> Vec<LogicalSeq>;
    fn read_page(&self, ix: u32) -> Result<PageBytes>;
    fn allocate_pages(&mut self, n: usize) -> Result<Vec<u32>>;
    fn write_page(&mut self, ix: u32, page: &PageBytes) -> Result<()>;
    fn install_logical_seqs(&mut self, seqs: &[LogicalSeq]) -> Result<()>;
}
Expand description

Engine-agnostic paged-cache interface. Implementations are not required to be thread-safe for read_page / write_page — the snapshot orchestrator holds a &mut self for the duration of capture/restore.

Required Methods§

Source

fn meta(&self) -> CacheMeta

Static cache metadata (page size, layer count, dtype, …).

Source

fn pause(&mut self) -> Result<()>

Pause the engine so the page table is stable. May be a no-op for adapters that already hold a write-lock during snapshot.

Source

fn resume(&mut self) -> Result<()>

Resume the engine after pause / restore.

Source

fn occupied_pages(&self) -> Vec<u32>

List physical-page indices that currently hold valid data.

Source

fn logical_seqs(&self) -> Vec<LogicalSeq>

Snapshot of every live logical sequence’s page-table mapping.

Source

fn read_page(&self, ix: u32) -> Result<PageBytes>

Read one (K, V) page out of the engine. Implementations return raw bytes of length meta.page_bytes() for each.

Source

fn allocate_pages(&mut self, n: usize) -> Result<Vec<u32>>

Allocate n fresh physical-page slots and return their indices in the order they should be filled. Restore writes pages in this order.

Source

fn write_page(&mut self, ix: u32, page: &PageBytes) -> Result<()>

Write one (K, V) page into the engine at the given physical-page index. The index MUST have been returned by a recent Self::allocate_pages call.

Source

fn install_logical_seqs(&mut self, seqs: &[LogicalSeq]) -> Result<()>

Re-install the per-request logical-seq → page-list mapping after restore. Called once, after all pages have been written.

Implementors§