GET TTL: Returns the remaining TTL in milliseconds for a key. - `None` — key does not exist (or is expired) - `Some(-1)` — key exists but has no TTL (persistent) - `Some(remaining_ms)` — key exists and expires in `remaining_ms` milliseconds
(
&self,
tenant_id: u64,
collection: &str,
key: &[u8],
now_ms: u64,
)
| 215 | /// - `Some(-1)` — key exists but has no TTL (persistent) |
| 216 | /// - `Some(remaining_ms)` — key exists and expires in `remaining_ms` milliseconds |
| 217 | pub fn get_ttl_ms( |
| 218 | &self, |
| 219 | tenant_id: u64, |
| 220 | collection: &str, |
| 221 | key: &[u8], |
| 222 | now_ms: u64, |
| 223 | ) -> Option<i64> { |
| 224 | let tkey = table_key(tenant_id, collection); |
| 225 | let table = self.tables.get(&tkey)?; |
| 226 | |
| 227 | // First check the key exists and isn't expired. |
| 228 | table.get(key, now_ms)?; |
| 229 | |
| 230 | // Now get the metadata for TTL info. |
| 231 | let meta = table.get_entry_meta(key)?; |
| 232 | if !meta.has_ttl { |
| 233 | Some(-1) |
| 234 | } else { |
| 235 | let remaining = meta.expire_at_ms.saturating_sub(now_ms); |
| 236 | Some(remaining as i64) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /// BATCH GET: fetch multiple keys. Returns values in order (None for missing). |
| 241 | pub fn batch_get( |