pub struct MemoryCache { /* private fields */ }Expand description
In-memory cache for testing and development
London School TDD Design:
- Implements Cache trait for collaboration contract
- Thread-safe with Arc<Mutex<>> for concurrent access
- No persistence - perfect for testing
- Fast operations without disk I/O
§Example
use clnrm_core::cache::{MemoryCache, Cache};
use std::path::Path;
let cache = MemoryCache::new();
let file_path = Path::new("tests/api.clnrm.toml");
let content = "rendered content";
if cache.has_changed(file_path, content)? {
// Run test
cache.update(file_path, content)?;
}Implementations§
Source§impl MemoryCache
impl MemoryCache
Trait Implementations§
Source§impl Cache for MemoryCache
impl Cache for MemoryCache
Source§fn has_changed(&self, file_path: &Path, rendered_content: &str) -> Result<bool>
fn has_changed(&self, file_path: &Path, rendered_content: &str) -> Result<bool>
Check if a file has changed since last cache update Read more
Source§fn update(&self, file_path: &Path, rendered_content: &str) -> Result<()>
fn update(&self, file_path: &Path, rendered_content: &str) -> Result<()>
Update cache with new file hash Read more
Source§fn stats(&self) -> Result<CacheStats>
fn stats(&self) -> Result<CacheStats>
Get cache statistics
Source§impl Clone for MemoryCache
impl Clone for MemoryCache
Source§fn clone(&self) -> MemoryCache
fn clone(&self) -> MemoryCache
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 MemoryCache
impl Debug for MemoryCache
Auto Trait Implementations§
impl Freeze for MemoryCache
impl RefUnwindSafe for MemoryCache
impl Send for MemoryCache
impl Sync for MemoryCache
impl Unpin for MemoryCache
impl UnwindSafe for MemoryCache
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request