pub struct CacheEntry {
pub query: String,
pub context: String,
pub response: String,
pub function_calls: Vec<String>,
pub created_at: i64,
pub hit_count: u32,
pub embedding: Option<Vec<f32>>,
}Expand description
A cached entry
Fields§
§query: StringOriginal query
context: StringContext used for the query
response: StringCached response
function_calls: Vec<String>Function/tool calls made
created_at: i64When the entry was created (Unix timestamp)
hit_count: u32Number of times this entry was hit
embedding: Option<Vec<f32>>Optional embedding for semantic matching
Implementations§
Source§impl CacheEntry
impl CacheEntry
Sourcepub fn new(
query: impl Into<String>,
context: impl Into<String>,
response: impl Into<String>,
function_calls: Vec<String>,
) -> Self
pub fn new( query: impl Into<String>, context: impl Into<String>, response: impl Into<String>, function_calls: Vec<String>, ) -> Self
Create a new cache entry
Sourcepub fn with_embedding(self, embedding: Vec<f32>) -> Self
pub fn with_embedding(self, embedding: Vec<f32>) -> Self
Create with embedding for semantic matching
Sourcepub fn record_hit(&mut self)
pub fn record_hit(&mut self)
Increment hit count
Sourcepub fn is_expired(&self, ttl_secs: i64) -> bool
pub fn is_expired(&self, ttl_secs: i64) -> bool
Check if entry is expired
Trait Implementations§
Source§impl Clone for CacheEntry
impl Clone for CacheEntry
Source§fn clone(&self) -> CacheEntry
fn clone(&self) -> CacheEntry
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 moreSource§impl Debug for CacheEntry
impl Debug for CacheEntry
Source§impl<'de> Deserialize<'de> for CacheEntry
impl<'de> Deserialize<'de> for CacheEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CacheEntry
impl RefUnwindSafe for CacheEntry
impl Send for CacheEntry
impl Sync for CacheEntry
impl Unpin for CacheEntry
impl UnsafeUnpin for CacheEntry
impl UnwindSafe for CacheEntry
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