Skip to main content

ExactCache

Struct ExactCache 

Source
pub struct ExactCache<S: AnswerStore = MemoryStore> { /* private fields */ }
Expand description

Exact-match cache for deterministic requests over an AnswerStore.

Implementations§

Source§

impl ExactCache<MemoryStore>

Source

pub fn new(max_entries: usize) -> Self

In memory, at most max_entries answers.

Source§

impl<S: AnswerStore> ExactCache<S>

Source

pub fn with_store(store: S) -> Self

Source

pub fn store(&self) -> &S

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl<S: AnswerStore> AnswerCache for ExactCache<S>

Honours may_read and may_store; get_rev / put_rev key on the revision too.

Source§

fn get(&self, model: &str, request: &Request) -> Option<CachedAnswer>

A stored answer for request on model.
Source§

fn put(&self, model: &str, request: &Request, answer: &CachedAnswer)

Offers a finished answer; the cache decides whether to keep it.
Source§

fn get_rev( &self, model: &str, revision: Option<&str>, request: &Request, ) -> Option<CachedAnswer>

A stored answer for request on model at weights revision (a Hugging Face commit, a file hash, a fine-tune id). With no revision this is get. The default misses when a revision is given, so a cache that doesn’t key on revisions never replays answers from other weights.
Source§

fn put_rev( &self, model: &str, revision: Option<&str>, request: &Request, answer: &CachedAnswer, )

Offers a finished answer from model at revision. The default keeps it only when no revision is given (see get_rev).

Auto Trait Implementations§

§

impl<S> Forget for ExactCache<S>

§

impl<S> Freeze for ExactCache<S>
where S: Freeze,

§

impl<S> Move for ExactCache<S>

§

impl<S> RefUnwindSafe for ExactCache<S>
where S: RefUnwindSafe,

§

impl<S> Send for ExactCache<S>

§

impl<S> Sync for ExactCache<S>

§

impl<S> Unpin for ExactCache<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for ExactCache<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for ExactCache<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.