Skip to main content

MemoryStoreConfig

Struct MemoryStoreConfig 

Source
pub struct MemoryStoreConfig { /* private fields */ }
Expand description

Configuration for a hard-bounded MemoryStore.

With the serde feature, this is an object containing max_keys, shard_count, max_expired_removals_per_check, and max_batch_size. Only max_keys is required when deserializing; omitted bounds use the same defaults as the constructors.

Implementations§

Source§

impl MemoryStoreConfig

Source

pub fn new(max_keys: usize) -> Result<Self, MemoryStoreConfigError>

Creates a configuration with a global hard maximum of max_keys stored counters.

The store uses one shard by default so the entire configured capacity is available regardless of key distribution. Increasing the shard count trades some capacity utilization under uneven key distribution for greater lock concurrency.

§Errors

Returns an error when max_keys is zero.

Source

pub fn with_shard_count( self, shard_count: usize, ) -> Result<Self, MemoryStoreConfigError>

Sets the number of independently locked shards.

The global key capacity is divided into fixed per-shard capacities. A full shard denies a new key even when another shard has unused capacity. An atomic batch that targets more distinct keys at a shard than its fixed capacity is rejected as structurally unsatisfiable.

§Errors

Returns an error when the shard count is zero or greater than the configured global key capacity.

Source

pub fn with_max_expired_removals_per_check( self, maximum: usize, ) -> Result<Self, MemoryStoreConfigError>

Sets the maximum expired entries removed from a shard per check that targets it.

An atomic batch receives this cleanup allowance for each check in the batch, applied to that check’s shard.

§Errors

Returns an error when maximum is zero.

Source

pub fn with_max_batch_size( self, maximum: usize, ) -> Result<Self, MemoryStoreConfigError>

Sets the largest atomic batch accepted by the store.

§Errors

Returns an error when maximum is zero.

Source

pub const fn max_keys(&self) -> usize

Returns the global hard maximum number of stored keys.

Source

pub const fn shard_count(&self) -> usize

Returns the number of independently locked shards.

Source

pub const fn max_expired_removals_per_check(&self) -> usize

Returns the cleanup work limit per check targeting a shard.

Source

pub const fn max_batch_size(&self) -> usize

Returns the largest accepted atomic batch.

Trait Implementations§

Source§

impl Clone for MemoryStoreConfig

Source§

fn clone(&self) -> MemoryStoreConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryStoreConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MemoryStoreConfig

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for MemoryStoreConfig

Source§

impl PartialEq for MemoryStoreConfig

Source§

fn eq(&self, other: &MemoryStoreConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for MemoryStoreConfig

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MemoryStoreConfig

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.