pub struct AccessPattern {
pub key: String,
pub access_times: Vec<u64>,
pub size_bytes: usize,
}Expand description
Historical access record for a single cache key.
Fields§
§key: StringThe cache key this record belongs to.
access_times: Vec<u64>Monotonically increasing Unix timestamps (seconds) of past accesses.
size_bytes: usizeCaller-supplied estimated byte size for this key’s value.
Implementations§
Source§impl AccessPattern
impl AccessPattern
Sourcepub fn frequency_per_hour(&self) -> f64
pub fn frequency_per_hour(&self) -> f64
Compute accesses per hour over the entire recorded history.
Returns 0.0 when fewer than two access timestamps are known (the
time-span is undefined).
Sourcepub fn predict_next_access(&self) -> Option<u64>
pub fn predict_next_access(&self) -> Option<u64>
Predict the next access timestamp using exponential inter-arrival smoothing (EMA with α = 0.3 on inter-arrival deltas).
Returns None when there are fewer than two data points.
Sourcepub fn periodicity_secs(&self) -> Option<f64>
pub fn periodicity_secs(&self) -> Option<f64>
Attempt to detect a dominant periodic inter-arrival time (in seconds) using normalised auto-correlation of the inter-arrival sequence.
Returns Some(period) when the highest off-zero auto-correlation peak
exceeds 0.3 (weak threshold to be liberal about detection). Returns
None when the sequence is too short or no clear periodicity is found.
Trait Implementations§
Source§impl Clone for AccessPattern
impl Clone for AccessPattern
Source§fn clone(&self) -> AccessPattern
fn clone(&self) -> AccessPattern
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more