pub struct ImageCache { /* private fields */ }Expand description
Caches image analysis results with TTL and LRU eviction.
Wraps ricecoder-storage’s CacheManager to provide image-specific caching with SHA256-based cache keys, TTL support, and LRU eviction.
Implementations§
Source§impl ImageCache
impl ImageCache
Sourcepub fn new() -> ImageResult<Self>
pub fn new() -> ImageResult<Self>
Create a new image cache with default settings.
Uses default cache paths:
- User cache:
~/.ricecoder/cache/images/ - Project cache:
projects/ricecoder/.agent/cache/images/
§Errors
Returns error if cache directory cannot be created
Sourcepub fn with_config(ttl_seconds: u64, max_size_mb: u64) -> ImageResult<Self>
pub fn with_config(ttl_seconds: u64, max_size_mb: u64) -> ImageResult<Self>
Sourcepub fn get(&self, image_hash: &str) -> ImageResult<Option<ImageAnalysisResult>>
pub fn get(&self, image_hash: &str) -> ImageResult<Option<ImageAnalysisResult>>
Sourcepub fn set(
&self,
image_hash: &str,
result: &ImageAnalysisResult,
) -> ImageResult<()>
pub fn set( &self, image_hash: &str, result: &ImageAnalysisResult, ) -> ImageResult<()>
Sourcepub fn exists(&self, image_hash: &str) -> ImageResult<bool>
pub fn exists(&self, image_hash: &str) -> ImageResult<bool>
Check if an image analysis is cached and not expired.
§Arguments
image_hash- SHA256 hash of the image
Sourcepub fn invalidate(&self, image_hash: &str) -> ImageResult<bool>
pub fn invalidate(&self, image_hash: &str) -> ImageResult<bool>
Sourcepub fn clear(&self) -> ImageResult<()>
pub fn clear(&self) -> ImageResult<()>
Sourcepub fn cleanup_expired(&self) -> ImageResult<usize>
pub fn cleanup_expired(&self) -> ImageResult<usize>
Sourcepub fn compute_hash(data: &[u8]) -> String
pub fn compute_hash(data: &[u8]) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageCache
impl RefUnwindSafe for ImageCache
impl Send for ImageCache
impl Sync for ImageCache
impl Unpin for ImageCache
impl UnwindSafe for ImageCache
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
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().