Skip to content

Commit

Permalink
Merge pull request #56 from ndelvalle/feat/cmds/getex
Browse files Browse the repository at this point in the history
Fix remove_ttl not fully removing ttl
  • Loading branch information
ndelvalle authored Oct 13, 2024
2 parents ac7cace + 59c3fc1 commit 24723cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -212,6 +214,7 @@ impl InnerStore {

type Key = String;

#[derive(Debug, Clone)]
pub struct Value {
pub data: Bytes,
pub expires_at: Option<Instant>,
Expand Down

0 comments on commit 24723cf

Please sign in to comment.