pub struct CacheStore { /* private fields */ }Expand description
CacheStore provides file caching with SHA-256 hash-based change detection
Implementations§
Source§impl CacheStore
impl CacheStore
Sourcepub fn new(config: CacheConfig) -> Result<Self, Error>
pub fn new(config: CacheConfig) -> Result<Self, Error>
Create a new cache store
Sourcepub fn estimate_tokens(text: &str) -> u64
pub fn estimate_tokens(text: &str) -> u64
Estimate tokens from character count.
Uses ~4 characters per token, which matches the average for GPT-4 and Claude tokenizers on typical source code. Ceiling division ensures non-empty inputs always count as at least 1 token.
The previous formula (chars * 0.75) overstated token counts by ~3x.
Sourcepub async fn read_file(
&self,
path: &str,
offset: Option<usize>,
limit: Option<usize>,
force: bool,
) -> Result<FileReadResult, Error>
pub async fn read_file( &self, path: &str, offset: Option<usize>, limit: Option<usize>, force: bool, ) -> Result<FileReadResult, Error>
Read a file with caching
Follows the TypeScript algorithm:
- Check if this session has read this file before (session_reads table)
- If not: return full content, cache it
- If yes and hash matches: return “[unchanged]”
- If yes and hash differs: compute diff, return diff
Sourcepub async fn get_stats(&self) -> Result<CacheStats, Error>
pub async fn get_stats(&self) -> Result<CacheStats, Error>
Get cache statistics
Auto Trait Implementations§
impl !Freeze for CacheStore
impl !RefUnwindSafe for CacheStore
impl Send for CacheStore
impl Sync for CacheStore
impl Unpin for CacheStore
impl UnsafeUnpin for CacheStore
impl !UnwindSafe for CacheStore
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