pub struct LruCs { /* private fields */ }Expand description
In-memory LRU content store, bounded by total byte capacity.
Maintains two indices:
cache:LruCache<Arc<Name>, CsEntry>— exact-match lookup in O(1).prefix_index:NameTrie<Arc<Name>>— maps each cached name to itself, enablingCanBePrefixlookups viafirst_descendant.
All insertions and evictions update both indices atomically under the lock.
An atomic entry count (entry_count) allows get() to short-circuit
without acquiring the Mutex when the CS is empty — eliminating lock
contention on the hot path for workloads that don’t cache (e.g. iperf).
Implementations§
Trait Implementations§
Source§impl ContentStore for LruCs
impl ContentStore for LruCs
Source§async fn get(&self, interest: &Interest) -> Option<CsEntry>
async fn get(&self, interest: &Interest) -> Option<CsEntry>
Look up a Data packet matching
interest.
Honours MustBeFresh and CanBePrefix selectors.Source§async fn insert(
&self,
data: Bytes,
name: Arc<Name>,
meta: CsMeta,
) -> InsertResult
async fn insert( &self, data: Bytes, name: Arc<Name>, meta: CsMeta, ) -> InsertResult
Store a Data packet. May evict least-recently-used entries to make room.
Source§fn capacity(&self) -> CsCapacity
fn capacity(&self) -> CsCapacity
Current capacity configuration.
Source§fn current_bytes(&self) -> usize
fn current_bytes(&self) -> usize
Total bytes currently used.
Source§fn set_capacity(&self, max_bytes: usize)
fn set_capacity(&self, max_bytes: usize)
Update the maximum byte capacity at runtime.
Source§fn variant_name(&self) -> &str
fn variant_name(&self) -> &str
Human-readable name of this CS implementation (e.g. “lru”, “sharded-lru”).
Auto Trait Implementations§
impl !Freeze for LruCs
impl RefUnwindSafe for LruCs
impl Send for LruCs
impl Sync for LruCs
impl Unpin for LruCs
impl UnwindSafe for LruCs
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