#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ExpireCondition {
#[default]
None,
NX,
XX,
GT,
LT,
}
impl ExpireCondition {
#[inline(always)]
pub const fn should_update(self, current_exp: u64, new_exp: u64) -> bool {
match self {
Self::None => true,
Self::NX => current_exp == 0,
Self::XX => current_exp > 0,
Self::GT => current_exp > 0 && new_exp > current_exp,
Self::LT => current_exp == 0 || new_exp < current_exp,
}
}
}