Skip to main content

evict

Function evict 

Source
pub fn evict(records: &mut Vec<StoredPsk>, live: Option<&str>) -> Option<usize>
Expand description

Drops the oldest record that is not live when records holds more than MAX_PAIRINGS.

Returns the index that was removed, or None when the list has room or every record belongs to the live server. The live record wins over the capacity floor: with only live records in the list nothing is removed.

This is the list form of the rule persist_pairing applies, for a caller that already holds the records. It operates on a list in insertion order (oldest first), which is the order Storage::load_pairings returns. The caller is responsible for a record it is about to store: persist_pairing keeps that record out of the list until after eviction.