pub struct CachingFetcher<CTXEXT, FENSLLM> {
pub inner: Arc<FENSLLM>,
/* private fields */
}Expand description
Wraps an Ensemble LLM fetcher with per-request deduplication caching.
When multiple parts of a request need the same Ensemble LLM, this fetcher ensures only one actual fetch is performed. Subsequent requests for the same Ensemble LLM ID within the same request context share the result.
Fields§
§inner: Arc<FENSLLM>The underlying fetcher to delegate to on cache miss.
Implementations§
Source§impl<CTXEXT, FENSLLM> CachingFetcher<CTXEXT, FENSLLM>
impl<CTXEXT, FENSLLM> CachingFetcher<CTXEXT, FENSLLM>
Source§impl<CTXEXT, FENSLLM> CachingFetcher<CTXEXT, FENSLLM>
impl<CTXEXT, FENSLLM> CachingFetcher<CTXEXT, FENSLLM>
Sourcepub fn spawn_fetches<'id>(
&self,
ctx: Context<CTXEXT>,
ids: impl Iterator<Item = &'id str>,
)
pub fn spawn_fetches<'id>( &self, ctx: Context<CTXEXT>, ids: impl Iterator<Item = &'id str>, )
Spawns concurrent fetch tasks for multiple Ensemble LLM IDs.
This allows pre-warming the cache when the set of required IDs is known ahead of time, reducing latency by parallelizing the fetches.
Sourcepub async fn fetch(
&self,
ctx: Context<CTXEXT>,
id: &str,
) -> Result<Option<(EnsembleLlm, u64)>, ResponseError>
pub async fn fetch( &self, ctx: Context<CTXEXT>, id: &str, ) -> Result<Option<(EnsembleLlm, u64)>, ResponseError>
Fetches an Ensemble LLM, 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, FENSLLM: Clone> Clone for CachingFetcher<CTXEXT, FENSLLM>
impl<CTXEXT: Clone, FENSLLM: Clone> Clone for CachingFetcher<CTXEXT, FENSLLM>
Source§fn clone(&self) -> CachingFetcher<CTXEXT, FENSLLM>
fn clone(&self) -> CachingFetcher<CTXEXT, FENSLLM>
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, FENSLLM> Freeze for CachingFetcher<CTXEXT, FENSLLM>
impl<CTXEXT, FENSLLM> RefUnwindSafe for CachingFetcher<CTXEXT, FENSLLM>where
CTXEXT: RefUnwindSafe,
FENSLLM: RefUnwindSafe,
impl<CTXEXT, FENSLLM> Send for CachingFetcher<CTXEXT, FENSLLM>
impl<CTXEXT, FENSLLM> Sync for CachingFetcher<CTXEXT, FENSLLM>
impl<CTXEXT, FENSLLM> Unpin for CachingFetcher<CTXEXT, FENSLLM>where
CTXEXT: Unpin,
impl<CTXEXT, FENSLLM> UnwindSafe for CachingFetcher<CTXEXT, FENSLLM>where
FENSLLM: 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