From 59c3fc10134b7daa90a1e20151780ae70481166b Mon Sep 17 00:00:00 2001 From: gillchristian Date: Sun, 13 Oct 2024 17:57:02 +0200 Subject: [PATCH] Fix remove_ttl not fully removing ttl --- src/store.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/store.rs b/src/store.rs index 189c83b..e06ce25 100644 --- a/src/store.rs +++ b/src/store.rs @@ -119,9 +119,11 @@ impl<'a> InnerStoreLocked<'a> { } pub fn remove_ttl(&mut self, key: &str) { - if let Some(value) = self.state.keys.get(key) { + // Drop the immutable reference to `self.state` by cloning. + if let Some(value) = self.state.keys.get(key).cloned() { if let Some(expires_at) = value.expires_at { self.state.ttls.remove(&(expires_at, key.to_string())); + self.set(key.to_string(), value.data); } } } @@ -212,6 +214,7 @@ impl InnerStore { type Key = String; +#[derive(Debug, Clone)] pub struct Value { pub data: Bytes, pub expires_at: Option,