pub struct ResponseCache { /* private fields */ }Expand description
The response cache — bounded LRU with TTL eviction.
Implementations§
Source§impl ResponseCache
impl ResponseCache
pub fn new(capacity: usize, ttl: Duration) -> ResponseCache
Sourcepub fn get(&mut self, key: u64) -> Option<&str>
pub fn get(&mut self, key: u64) -> Option<&str>
Look up a cache key. Returns the cached response if found and not expired.
Sourcepub fn put(&mut self, key: u64, response: String, _output_tokens: u64)
pub fn put(&mut self, key: u64, response: String, _output_tokens: u64)
Insert a response into the cache.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Forget for ResponseCache
impl Freeze for ResponseCache
impl Move for ResponseCache
impl RefUnwindSafe for ResponseCache
impl Send for ResponseCachewhere
RawVecInner: Send,
impl Sync for ResponseCachewhere
RawVecInner: Sync,
impl Unpin for ResponseCache
impl UnsafeUnpin for ResponseCache
impl UnwindSafe for ResponseCachewhere
RawVecInner: 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
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