pub struct DiskOffloadRepository { /* private fields */ }Expand description
CacheRepository decorator that offloads entry payloads to disk.
Wraps any index backend; see the module docs for the blob
lifecycle and failure policy. stale_retention, sweep_interval, and
payload_max_ttl must be non-zero (the payload intervals at least one
second — the death epoch truncates to whole seconds) — enforced by
CacheRepoConfig validation, not here.
Implementations§
Source§impl DiskOffloadRepository
impl DiskOffloadRepository
Sourcepub fn new(
inner: Arc<dyn CacheRepository>,
dir: PathBuf,
stale_retention: Duration,
sweep_interval: Duration,
payload_max_ttl: Duration,
shutdown_token: CancellationToken,
) -> Self
pub fn new( inner: Arc<dyn CacheRepository>, dir: PathBuf, stale_retention: Duration, sweep_interval: Duration, payload_max_ttl: Duration, shutdown_token: CancellationToken, ) -> Self
Wrap inner with disk payload offload into dir (production clock).
The shutdown_token stops the background payload sweeper; it is
owned by the sweeper task and never cancelled by the decorator.
Sourcepub fn with_clock(
inner: Arc<dyn CacheRepository>,
dir: PathBuf,
stale_retention: Duration,
sweep_interval: Duration,
payload_max_ttl: Duration,
shutdown_token: CancellationToken,
clock: OffloadClock,
) -> Self
pub fn with_clock( inner: Arc<dyn CacheRepository>, dir: PathBuf, stale_retention: Duration, sweep_interval: Duration, payload_max_ttl: Duration, shutdown_token: CancellationToken, clock: OffloadClock, ) -> Self
Test seam: Self::new with an injected OffloadClock.
The injected clock drives death-epoch math only; the spawned sweeper always sweeps on the real clock.
Trait Implementations§
Source§impl CacheRepository for DiskOffloadRepository
impl CacheRepository for DiskOffloadRepository
Source§fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delegate-only: the index row is dropped here; the payload blob becomes an orphan reclaimed asynchronously at its filename-encoded death epoch.
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reclaim payload space now: best-effort unlink of every entry of
the payload dir, then delegate to the index. Unlink failures
never turn clear into Err — each failure WARNs and the rest
of the dir is still attempted.
Source§fn invalidate_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64, CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invalidate_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64, CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delegate-only: the returned count is index-scoped; payload blobs are reclaimed asynchronously at their filename-encoded death epoch.