ShardedCs

Struct ShardedCs 

Source
pub struct ShardedCs<C: ContentStore> { /* private fields */ }
Expand description

Shards a ContentStore across N instances to reduce lock contention.

Shard selection is by first name component (not full name hash) so that related content (/video/seg/1, /video/seg/2) lands in the same shard, preserving LRU locality for sequential access.

The shard count is the length of the shards Vec and is fixed at construction time.

Implementations§

Source§

impl<C: ContentStore> ShardedCs<C>

Source

pub fn new(shards: Vec<C>) -> Self

Create a ShardedCs from pre-constructed inner stores.

§Panics

Panics if shards is empty.

Source

pub fn shard_count(&self) -> usize

Number of shards.

Trait Implementations§

Source§

impl<C: ContentStore> ContentStore for ShardedCs<C>

Source§

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

Store a Data packet. May evict least-recently-used entries to make room.
Source§

async fn evict(&self, name: &Name) -> bool

Explicitly evict the entry for name.
Source§

fn capacity(&self) -> CsCapacity

Current capacity configuration.
Source§

fn len(&self) -> usize

Number of entries currently cached.
Source§

fn current_bytes(&self) -> usize

Total bytes currently used.
Source§

fn set_capacity(&self, max_bytes: usize)

Update the maximum byte capacity at runtime.
Source§

fn variant_name(&self) -> &str

Human-readable name of this CS implementation (e.g. “lru”, “sharded-lru”).
Source§

async fn evict_prefix(&self, prefix: &Name, limit: Option<usize>) -> usize

Evict all entries matching prefix, up to limit entries (None = unlimited). Returns the number of entries evicted.
Source§

fn stats(&self) -> CsStats

Snapshot of hit/miss/insert/eviction counters.
Source§

fn is_empty(&self) -> bool

Returns true if the content store contains no entries.

Auto Trait Implementations§

§

impl<C> Freeze for ShardedCs<C>

§

impl<C> RefUnwindSafe for ShardedCs<C>
where C: RefUnwindSafe,

§

impl<C> Send for ShardedCs<C>

§

impl<C> Sync for ShardedCs<C>

§

impl<C> Unpin for ShardedCs<C>
where C: Unpin,

§

impl<C> UnwindSafe for ShardedCs<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedContentStore for T
where T: ContentStore,

Source§

fn get_erased<'a>( &'a self, interest: &'a Interest, ) -> Pin<Box<dyn Future<Output = Option<CsEntry>> + Send + 'a>>

Source§

fn insert_erased( &self, data: Bytes, name: Arc<Name>, meta: CsMeta, ) -> Pin<Box<dyn Future<Output = InsertResult> + Send + '_>>

Source§

fn evict_erased<'a>( &'a self, name: &'a Name, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>

Source§

fn evict_prefix_erased<'a>( &'a self, prefix: &'a Name, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'a>>

Source§

fn capacity(&self) -> CsCapacity

Source§

fn set_capacity(&self, max_bytes: usize)

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn current_bytes(&self) -> usize

Source§

fn variant_name(&self) -> &str

Source§

fn stats(&self) -> CsStats

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.