pub struct InMemoryFeedCache { /* private fields */ }Expand description
What: Provide a small deterministic in-memory implementation of FeedCache.
Inputs:
- Constructed with
InMemoryFeedCache::newand a maximum entry count.
Output:
- A thread-safe cache suitable for short-lived applications and tests.
Details:
- This implementation has no time-to-live policy; use a caller-provided cache when persistence or expiration is required.
- On capacity pressure it removes the lexically first key, keeping eviction deterministic without adding an AUR-coupled cache dependency.
Implementations§
Source§impl InMemoryFeedCache
impl InMemoryFeedCache
Sourcepub fn new(capacity: usize) -> Result<Self>
pub fn new(capacity: usize) -> Result<Self>
What: Create an empty in-memory feed cache with an explicit capacity.
Inputs:
capacity: Maximum number of feed payloads that may be retained.
Output:
- A ready-to-use cache, or
InvalidInputwhen capacity is zero.
Details:
- The explicit non-zero bound prevents unbounded cache construction and keeps memory ownership visible to callers.
§Errors
Returns ArchToolkitError::InvalidInput when capacity is zero.
Trait Implementations§
Source§impl Debug for InMemoryFeedCache
impl Debug for InMemoryFeedCache
Source§impl FeedCache for InMemoryFeedCache
impl FeedCache for InMemoryFeedCache
Source§fn get(&self, key: &str) -> Result<Option<String>>
fn get(&self, key: &str) -> Result<Option<String>>
What: Return a cloned payload for the requested feed key.
Inputs:
key: Feed cache key to look up.
Output:
- The stored payload when present, otherwise
None.
Details:
- Recovers the in-memory cache after a poisoned mutex because payloads are independent values and the map remains usable.
Source§fn put(&self, key: &str, value: &str) -> Result<()>
fn put(&self, key: &str, value: &str) -> Result<()>
What: Store a payload and evict deterministically when full.
Inputs:
key: Feed cache key to write.value: Raw successful feed payload.
Output:
Ok(())after the in-memory map is updated.
Details:
- Updating an existing key does not evict another entry.
- A new key evicts the lexically first existing key only at capacity.
Auto Trait Implementations§
impl !Freeze for InMemoryFeedCache
impl RefUnwindSafe for InMemoryFeedCache
impl Send for InMemoryFeedCache
impl Sync for InMemoryFeedCache
impl Unpin for InMemoryFeedCache
impl UnsafeUnpin for InMemoryFeedCache
impl UnwindSafe for InMemoryFeedCache
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