pub struct ScoringWeights {
pub recency_exp: f64,
pub priority_exp: f64,
pub size_exp: f64,
pub per_type_priority: HashMap<String, f64>,
}Expand description
Configurable exponent weights used by score_for_eviction.
The eviction score formula is:
score = (1 - recency).powf(recency_exp)
× (1/priority).powf(priority_exp)
× size_factor.powf(size_exp)Defaults (recency_exp = 1.0, priority_exp = 1.0, size_exp = 1.0)
reproduce the original behaviour exactly.
per_type_priority overrides the priority weight multiplier per
MediaContentType variant; keys are matched by discriminant tag, so
only the variant kind matters (e.g. all VideoSegment variants share one
entry).
Fields§
§recency_exp: f64Exponent applied to the recency factor (1 - recency). Higher = aged
entries are penalised more aggressively.
priority_exp: f64Exponent applied to (1 / priority). Higher = low-priority items are
more strongly preferred for eviction.
size_exp: f64Exponent applied to size_factor. Higher = large entries are more
strongly preferred for eviction.
per_type_priority: HashMap<String, f64>Per-type priority weight override. When a content type has an entry
here, its priority value is multiplied by this factor before the
scoring formula is applied. Values < 1.0 make the type harder to
evict; values > 1.0 make it easier to evict.
Implementations§
Source§impl ScoringWeights
impl ScoringWeights
Sourcepub fn priority_multiplier(&self, content_type: &MediaContentType) -> f64
pub fn priority_multiplier(&self, content_type: &MediaContentType) -> f64
Look up the priority multiplier for a content type.
Trait Implementations§
Source§impl Clone for ScoringWeights
impl Clone for ScoringWeights
Source§fn clone(&self) -> ScoringWeights
fn clone(&self) -> ScoringWeights
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more