Function cleanup_old_timestamps

Source
pub fn cleanup_old_timestamps(
    timestamps: &mut Vec<Instant>,
    cutoff: Instant,
) -> usize
Expand description

Clean up timestamps older than the specified cutoff time

This function removes all timestamps from a collection that are older than the cutoff time, helping to prevent unbounded memory growth in rate limiters that track individual request timestamps.

§Arguments

  • timestamps - Mutable reference to a vector of timestamps
  • cutoff - The cutoff instant; timestamps older than this will be removed

§Returns

The number of timestamps that were removed