in src/storage/seg/src/ttl_buckets/ttl_bucket.rs [146:172]
fn try_expand(&mut self, segments: &mut Segments) -> Result<(), TtlBucketsError> {
if let Some(id) = segments.pop_free() {
{
if let Some(tail_id) = self.tail {
let mut tail = segments.get_mut(tail_id).unwrap();
tail.set_next_seg(Some(id));
}
}
let mut segment = segments.get_mut(id).unwrap();
segment.set_prev_seg(self.tail);
segment.set_next_seg(None);
segment.set_ttl(Duration::from_secs(self.ttl as u32));
if self.head.is_none() {
debug_assert!(self.tail.is_none());
self.head = Some(id);
}
self.tail = Some(id);
self.nseg += 1;
debug_assert!(!segment.evictable(), "segment should not be evictable");
segment.set_evictable(true);
segment.set_accessible(true);
Ok(())
} else {
Err(TtlBucketsError::NoFreeSegments)
}
}