pub struct CacheEntry {
pub hash: String,
pub line_count: usize,
pub original_tokens: usize,
pub path: String,
pub stored_mtime: Option<SystemTime>,
pub compressed_outputs: HashMap<String, String>,
pub full_content_delivered: bool,
pub last_mode: String,
/* private fields */
}Expand description
A cached file read: zstd-compressed content, hash, token count, and access metadata.
read_count and last_access use interior mutability (atomics) so cache
hits can be recorded under a shared (read) lock — parallel reads of distinct
files no longer serialize on a global write lock.
Fields§
§hash: String§line_count: usize§original_tokens: usize§path: String§stored_mtime: Option<SystemTime>§compressed_outputs: HashMap<String, String>Mode-specific compressed outputs (e.g. “map”, “signatures”) cached to avoid re-parsing.
full_content_delivered: boolWhether full (uncompressed) content was already delivered for this hash. Prevents cache-stub loops when upgrading from compressed to full mode.
last_mode: StringLast read mode used for this file (for auto-escalation on edit failure).
Implementations§
Source§impl CacheEntry
impl CacheEntry
Sourcepub fn new(
content: &str,
hash: String,
line_count: usize,
original_tokens: usize,
path: String,
stored_mtime: Option<SystemTime>,
) -> Self
pub fn new( content: &str, hash: String, line_count: usize, original_tokens: usize, path: String, stored_mtime: Option<SystemTime>, ) -> Self
Creates a new entry with zstd-compressed content.
Sourcepub fn read_count(&self) -> u32
pub fn read_count(&self) -> u32
Current read count (lock-free).
Sourcepub fn bump_read_count(&self) -> u32
pub fn bump_read_count(&self) -> u32
Atomically increments the read count and returns the new value (lock-free).
Sourcepub fn set_read_count(&self, n: u32)
pub fn set_read_count(&self, n: u32)
Overwrites the read count (used by store and tests).
Sourcepub fn last_access(&self) -> Instant
pub fn last_access(&self) -> Instant
Last access time, decoded from the atomic millisecond offset.
Sourcepub fn set_last_access(&self, when: Instant)
pub fn set_last_access(&self, when: Instant)
Overwrites the last-access time (used by tests and eviction setup).
Sourcepub fn set_content(&mut self, content: &str)
pub fn set_content(&mut self, content: &str)
Replaces the stored content with new zstd-compressed data.
Sourcepub fn compressed_size(&self) -> usize
pub fn compressed_size(&self) -> usize
Approximate RAM usage of the compressed content in bytes.
Source§impl CacheEntry
impl CacheEntry
Sourcepub fn eviction_score_legacy(&self, now: Instant) -> f64
pub fn eviction_score_legacy(&self, now: Instant) -> f64
Computes a legacy eviction score blending recency, frequency, and size.
pub fn get_compressed(&self, mode_key: &str) -> Option<&String>
pub fn set_compressed(&mut self, mode_key: &str, output: String)
pub fn mark_full_delivered(&mut self)
Trait Implementations§
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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