From 537df4d28435a5a4f1d6ff43c01b6fa2a30a03d2 Mon Sep 17 00:00:00 2001 From: bittcrafter Date: Sat, 28 Jun 2025 19:54:44 +0800 Subject: [PATCH 1/3] chore(storage): bump version from 0.6.0 to 0.6.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c2989f8..82ea826 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rmqtt-storage" -version = "0.6.0" +version = "0.6.1" authors = ["rmqtt "] edition = "2021" license = "MIT OR Apache-2.0" From 5b1bbffd2293745a4f459c6bd8937ecc3a1f97d8 Mon Sep 17 00:00:00 2001 From: bittcrafter Date: Sat, 28 Jun 2025 19:56:38 +0800 Subject: [PATCH 2/3] test(storage): update test configuration to use Sled storage --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5c9d6b0..a630692 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,7 +119,7 @@ mod tests { fn get_cfg(name: &str) -> Config { let cfg = Config { - typ: StorageType::RedisCluster, + typ: StorageType::Sled, sled: SledConfig { path: format!("./.catch/{}", name), cleanup_f: |_db| {}, From 9c872c930496afc7ca473ba947dea2c755d64734 Mon Sep 17 00:00:00 2001 From: bittcrafter Date: Sat, 28 Jun 2025 20:03:25 +0800 Subject: [PATCH 3/3] fix(storage): improve TTL feature handling in contains_key operations - Added proper conditional compilation for TTL feature in contains_key methods: * _self_map_contains_key * _self_list_contains_key * _self_contains_key - Without TTL feature, now directly checks underlying storage: * Calls _map_contains_key for map storage * Calls _list_contains_key for list storage * Calls _kv_contains_key for key-value storage - Maintains TTL expiration checks when feature is enabled --- src/storage_sled.rs | 52 +++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/storage_sled.rs b/src/storage_sled.rs index 8a6f103..a6c952e 100644 --- a/src/storage_sled.rs +++ b/src/storage_sled.rs @@ -1129,24 +1129,35 @@ impl SledStorageDB { #[inline] fn _self_map_contains_key(&self, key: &[u8]) -> Result { - // let this = self; - if self._is_expired(key, |k| Self::_map_contains_key(&self.map_tree, k))? { - Ok(false) - } else { - //Self::_map_contains_key(&self.map_tree, key) - Ok(true) + #[cfg(feature = "ttl")] + { + if self._is_expired(key, |k| Self::_map_contains_key(&self.map_tree, k))? { + Ok(false) + } else { + //Self::_map_contains_key(&self.map_tree, key) + Ok(true) + } } + + #[cfg(not(feature = "ttl"))] + Self::_map_contains_key(&self.map_tree, key) } #[inline] fn _self_list_contains_key(&self, key: &[u8]) -> Result { - let this = self; - if this._is_expired(key, |k| Self::_list_contains_key(&self.list_tree, k))? { - Ok(false) - } else { - // Self::_list_contains_key(&this.list_tree, key) - Ok(true) + #[cfg(feature = "ttl")] + { + let this = self; + if this._is_expired(key, |k| Self::_list_contains_key(&self.list_tree, k))? { + Ok(false) + } else { + // Self::_list_contains_key(&this.list_tree, key) + Ok(true) + } } + + #[cfg(not(feature = "ttl"))] + Self::_list_contains_key(&self.list_tree, key) } #[inline] @@ -1308,13 +1319,18 @@ impl SledStorageDB { #[inline] fn _self_contains_key(&self, key: &[u8]) -> Result { - let this = self; - if this._is_expired(key, |k| Self::_kv_contains_key(&self.kv_tree, k))? { - Ok(false) - } else { - // this._contains_key(key, KeyType::KV) - Ok(true) + #[cfg(feature = "ttl")] + { + let this = self; + if this._is_expired(key, |k| Self::_kv_contains_key(&self.kv_tree, k))? { + Ok(false) + } else { + // this._contains_key(key, KeyType::KV) + Ok(true) + } } + #[cfg(not(feature = "ttl"))] + Self::_kv_contains_key(&self.kv_tree, key) } #[inline]