pub struct CachedResponse {
pub response: CompletionResponse,
pub created_at: SystemTime,
pub hit_count: Arc<AtomicU64>,
}Expand description
A cached response with metadata.
Fields§
§response: CompletionResponseThe cached response.
created_at: SystemTimeWhen this entry was created.
hit_count: Arc<AtomicU64>Number of times this entry was hit.
Implementations§
Source§impl CachedResponse
impl CachedResponse
Sourcepub fn new(response: CompletionResponse) -> Self
pub fn new(response: CompletionResponse) -> Self
Create a new cached response.
Sourcepub fn is_expired(&self, ttl: Duration) -> bool
pub fn is_expired(&self, ttl: Duration) -> bool
Check if this entry has expired.
Sourcepub fn record_hit(&self) -> u64
pub fn record_hit(&self) -> u64
Increment the hit count and return the new value.
Trait Implementations§
Source§impl Clone for CachedResponse
impl Clone for CachedResponse
Source§fn clone(&self) -> CachedResponse
fn clone(&self) -> CachedResponse
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 Freeze for CachedResponse
impl RefUnwindSafe for CachedResponse
impl Send for CachedResponse
impl Sync for CachedResponse
impl Unpin for CachedResponse
impl UnwindSafe for CachedResponse
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