pub struct SessionCache { /* private fields */ }Expand description
In-memory file cache with RRF-based eviction, file references, and cross-file dedup.
Implementations§
Source§impl SessionCache
impl SessionCache
Sourcepub fn get_file_ref(&mut self, path: &str) -> String
pub fn get_file_ref(&mut self, path: &str) -> String
Returns or assigns a short file reference label (F1, F2, …) for the given path.
Sourcepub fn get_file_ref_readonly(&self, path: &str) -> Option<String>
pub fn get_file_ref_readonly(&self, path: &str) -> Option<String>
Returns the file reference label for a path without assigning a new one.
Sourcepub fn get(&self, path: &str) -> Option<&CacheEntry>
pub fn get(&self, path: &str) -> Option<&CacheEntry>
Looks up a cached entry by file path.
Sourcepub fn record_cache_hit(&mut self, path: &str) -> Option<&CacheEntry>
pub fn record_cache_hit(&mut self, path: &str) -> Option<&CacheEntry>
Records a cache hit, updates access stats, and emits a cache-hit event.
Sourcepub fn store(&mut self, path: &str, content: String) -> StoreResult
pub fn store(&mut self, path: &str, content: String) -> StoreResult
Stores file content in the cache; returns a hit if content hash matches.
Sourcepub fn total_cached_tokens(&self) -> usize
pub fn total_cached_tokens(&self) -> usize
Returns the sum of original token counts across all cached entries.
Sourcepub fn evict_if_needed(&mut self, incoming_tokens: usize)
pub fn evict_if_needed(&mut self, incoming_tokens: usize)
Evict lowest-scoring entries (by RRF) until cache fits within token budget.
Sourcepub fn get_all_entries(&self) -> Vec<(&String, &CacheEntry)>
pub fn get_all_entries(&self) -> Vec<(&String, &CacheEntry)>
Returns all cached entries as (path, entry) pairs.
Sourcepub fn get_stats(&self) -> &CacheStats
pub fn get_stats(&self) -> &CacheStats
Returns a reference to the aggregated cache statistics.
Sourcepub fn file_ref_map(&self) -> &HashMap<String, String>
pub fn file_ref_map(&self) -> &HashMap<String, String>
Returns the path-to-file-ref mapping (e.g. “/src/main.rs” → “F1”).
Replaces the cross-file shared blocks used for deduplication.
Returns the current set of cross-file shared blocks.
Sourcepub fn apply_dedup(&self, path: &str, content: &str) -> Option<String>
pub fn apply_dedup(&self, path: &str, content: &str) -> Option<String>
Replace shared blocks in content with cross-file references.
Sourcepub fn invalidate(&mut self, path: &str) -> bool
pub fn invalidate(&mut self, path: &str) -> bool
Removes a file from the cache, forcing a fresh read on next access.
Sourcepub fn get_compressed(&self, path: &str, mode_key: &str) -> Option<&String>
pub fn get_compressed(&self, path: &str, mode_key: &str) -> Option<&String>
Returns a cached compressed output for a given file and mode key.
Sourcepub fn mark_full_delivered(&mut self, path: &str)
pub fn mark_full_delivered(&mut self, path: &str)
Marks that full (uncompressed) content was delivered for this file.
Sourcepub fn set_compressed(&mut self, path: &str, mode_key: &str, output: String)
pub fn set_compressed(&mut self, path: &str, mode_key: &str, output: String)
Stores a compressed output for a given file and mode key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionCache
impl RefUnwindSafe for SessionCache
impl Send for SessionCache
impl Sync for SessionCache
impl Unpin for SessionCache
impl UnsafeUnpin for SessionCache
impl UnwindSafe for SessionCache
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
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>
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>
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