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
impl MemoryStoreConfig
Sourcepub fn new(max_keys: usize) -> Result<Self, MemoryStoreConfigError>
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.
Sourcepub fn with_shard_count(
self,
shard_count: usize,
) -> Result<Self, MemoryStoreConfigError>
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.
Sourcepub fn with_max_expired_removals_per_check(
self,
maximum: usize,
) -> Result<Self, MemoryStoreConfigError>
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.
Sourcepub fn with_max_batch_size(
self,
maximum: usize,
) -> Result<Self, MemoryStoreConfigError>
pub fn with_max_batch_size( self, maximum: usize, ) -> Result<Self, MemoryStoreConfigError>
Sourcepub const fn shard_count(&self) -> usize
pub const fn shard_count(&self) -> usize
Returns the number of independently locked shards.
Sourcepub const fn max_expired_removals_per_check(&self) -> usize
pub const fn max_expired_removals_per_check(&self) -> usize
Returns the cleanup work limit per check targeting a shard.
Sourcepub const fn max_batch_size(&self) -> usize
pub const fn max_batch_size(&self) -> usize
Returns the largest accepted atomic batch.
Trait Implementations§
Source§impl Clone for MemoryStoreConfig
impl Clone for MemoryStoreConfig
Source§fn clone(&self) -> MemoryStoreConfig
fn clone(&self) -> MemoryStoreConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryStoreConfig
impl Debug for MemoryStoreConfig
Source§impl<'de> Deserialize<'de> for MemoryStoreConfig
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MemoryStoreConfig
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for MemoryStoreConfig
Source§impl PartialEq for MemoryStoreConfig
impl PartialEq for MemoryStoreConfig
Source§impl Serialize for MemoryStoreConfig
Available on crate feature serde only.
impl Serialize for MemoryStoreConfig
serde only.