pub struct TieredBackend { /* private fields */ }Expand description
Three-tier read-through / write-through cache resolver.
Holds Arc<dyn StorageBackend> per tier, so any backend composes — the real
deployment injects RedisBackend (L1), PgStorageBackend (L2), S3Storage
(L3); tests inject in-memory mocks + a LocalStorage.
Implementations§
Source§impl TieredBackend
impl TieredBackend
Sourcepub fn new(
l1: Arc<dyn StorageBackend>,
l2: Arc<dyn StorageBackend>,
l3: Arc<dyn StorageBackend>,
) -> Self
pub fn new( l1: Arc<dyn StorageBackend>, l2: Arc<dyn StorageBackend>, l3: Arc<dyn StorageBackend>, ) -> Self
Compose three tiers with the default WritePolicy::WriteThrough.
Sourcepub fn with_write_policy(
l1: Arc<dyn StorageBackend>,
l2: Arc<dyn StorageBackend>,
l3: Arc<dyn StorageBackend>,
write_policy: WritePolicy,
) -> Self
pub fn with_write_policy( l1: Arc<dyn StorageBackend>, l2: Arc<dyn StorageBackend>, l3: Arc<dyn StorageBackend>, write_policy: WritePolicy, ) -> Self
Compose three tiers with an explicit WritePolicy.
Sourcepub fn write_policy(&self) -> WritePolicy
pub fn write_policy(&self) -> WritePolicy
The active write policy.
Trait Implementations§
Source§impl StorageBackend for TieredBackend
impl StorageBackend for TieredBackend
Source§fn wipe_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn wipe_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fan the wipe out to EVERY tier (L1 hot + L2/L3 durable), so a cache-wipe
clears all three at once. Best-effort per tier (mirrors delete): one
tier’s failure is logged, never aborting the others — the whole point is
to return the store to cold. Reports the largest per-tier narinfo count
removed (the authoritative tiers’ full set).
Source§fn get_narinfo<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_narinfo<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve narinfo text by store path hash.
Source§fn get_nar<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_nar<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a NAR blob by its relative path.
Source§fn put_narinfo<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
content: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_narinfo<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
content: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store narinfo text keyed by store path hash.
Source§fn put_nar<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
data: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_nar<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
data: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store a NAR blob at the given relative path.
Auto Trait Implementations§
impl !RefUnwindSafe for TieredBackend
impl !UnwindSafe for TieredBackend
impl Freeze for TieredBackend
impl Send for TieredBackend
impl Sync for TieredBackend
impl Unpin for TieredBackend
impl UnsafeUnpin for TieredBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more