pub struct CachingFetcher<CTXEXT, FENS> {
pub inner: Arc<FENS>,
/* private fields */
}Expand description
Wraps an ensemble fetcher with per-request deduplication caching.
When multiple parts of a request need the same ensemble, this fetcher ensures only one actual fetch is performed. Subsequent requests for the same ensemble ID within the same request context share the result.
Fields§
§inner: Arc<FENS>The underlying fetcher to delegate to on cache miss.
Implementations§
Source§impl<CTXEXT, FENS> CachingFetcher<CTXEXT, FENS>
impl<CTXEXT, FENS> CachingFetcher<CTXEXT, FENS>
Source§impl<CTXEXT, FENS> CachingFetcher<CTXEXT, FENS>
impl<CTXEXT, FENS> CachingFetcher<CTXEXT, FENS>
Sourcepub async fn fetch(
&self,
ctx: Context<CTXEXT>,
id: &str,
) -> Result<Option<(Ensemble, u64)>, ResponseError>
pub async fn fetch( &self, ctx: Context<CTXEXT>, id: &str, ) -> Result<Option<(Ensemble, u64)>, ResponseError>
Fetches an ensemble, using the request-scoped cache for deduplication.
If another fetch for the same ID is already in progress within this request context, waits for and shares that result instead of fetching again.
Trait Implementations§
Source§impl<CTXEXT: Clone, FENS: Clone> Clone for CachingFetcher<CTXEXT, FENS>
impl<CTXEXT: Clone, FENS: Clone> Clone for CachingFetcher<CTXEXT, FENS>
Source§fn clone(&self) -> CachingFetcher<CTXEXT, FENS>
fn clone(&self) -> CachingFetcher<CTXEXT, FENS>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<CTXEXT, FENS> Freeze for CachingFetcher<CTXEXT, FENS>
impl<CTXEXT, FENS> RefUnwindSafe for CachingFetcher<CTXEXT, FENS>where
CTXEXT: RefUnwindSafe,
FENS: RefUnwindSafe,
impl<CTXEXT, FENS> Send for CachingFetcher<CTXEXT, FENS>
impl<CTXEXT, FENS> Sync for CachingFetcher<CTXEXT, FENS>
impl<CTXEXT, FENS> Unpin for CachingFetcher<CTXEXT, FENS>where
CTXEXT: Unpin,
impl<CTXEXT, FENS> UnwindSafe for CachingFetcher<CTXEXT, FENS>where
FENS: RefUnwindSafe,
CTXEXT: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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