pub struct DataStoreConfig {
pub max_entries: usize,
pub max_entry_size: usize,
pub default_ttl: Option<Duration>,
pub max_ttl: Option<Duration>,
pub enable_metrics: bool,
pub memory_alert_threshold: f64,
}Expand description
Configuration for the DataStore component.
Controls storage limits, TTL behavior, capacity management, and metrics.
§TTL Semantics
default_ttl: Nonemeans entries without explicit TTL will effectively never expire. The implementation uses an internal sentinel cap of 10 years (not user-configurable).max_ttl: Nonemeans no user-configured upper limit on TTL values. The implementation uses an internal sentinel cap of 10 years (not user-configurable).- If both are
Some, the effective TTL will always respectmax_ttlconstraints
§Examples
use std::time::Duration;
use cedarling::DataStoreConfig;
// No configured expiration (uses internal long sentinel TTL)
let config = DataStoreConfig {
default_ttl: None, // No automatic expiration
max_ttl: None, // No user-configured upper limit
..Default::default()
};
// All entries expire after 5 minutes by default, max 1 hour
// When both are Some, max_ttl constrains the effective TTL
let config = DataStoreConfig {
default_ttl: Some(Duration::from_secs(300)), // 5 minutes
max_ttl: Some(Duration::from_secs(3600)), // 1 hour (constrains effective TTL)
..Default::default()
};Fields§
§max_entries: usizeMaximum number of data entries (0 = unlimited)
max_entry_size: usizeMaximum size per entry in bytes (0 = unlimited)
default_ttl: Option<Duration>Default TTL for entries without explicit expiration.
None means entries effectively never expire.
The implementation uses an internal sentinel cap of 10 years (not user-configurable).
max_ttl: Option<Duration>Maximum allowed TTL.
None means no user-configured upper limit on TTL values.
The implementation uses an internal sentinel cap of 10 years (not user-configurable).
enable_metrics: boolEnable metrics tracking (access counts, timestamps)
memory_alert_threshold: f64Memory usage alert threshold as a percentage (0.0-100.0). When capacity usage exceeds this threshold, an alert is triggered. Default: 80.0 (80%)
Implementations§
Source§impl DataStoreConfig
impl DataStoreConfig
Sourcepub fn validate(&self) -> Result<(), ConfigValidationError>
pub fn validate(&self) -> Result<(), ConfigValidationError>
Validate the configuration for consistency.
Returns ConfigValidationError when default_ttl exceeds max_ttl (if both are set)
or when memory_alert_threshold is outside the range 0.0..=100.0.
Trait Implementations§
Source§impl Clone for DataStoreConfig
impl Clone for DataStoreConfig
Source§fn clone(&self) -> DataStoreConfig
fn clone(&self) -> DataStoreConfig
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 DataStoreConfig
impl Debug for DataStoreConfig
Source§impl Default for DataStoreConfig
impl Default for DataStoreConfig
Source§impl PartialEq for DataStoreConfig
impl PartialEq for DataStoreConfig
impl StructuralPartialEq for DataStoreConfig
Auto Trait Implementations§
impl Freeze for DataStoreConfig
impl RefUnwindSafe for DataStoreConfig
impl Send for DataStoreConfig
impl Sync for DataStoreConfig
impl Unpin for DataStoreConfig
impl UnsafeUnpin for DataStoreConfig
impl UnwindSafe for DataStoreConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request