From f12ba35f5b26a7f81c2e0c9bdfdbcd03c76f46f0 Mon Sep 17 00:00:00 2001 From: anotherJJz <470623352@qq.com> Date: Thu, 24 Oct 2024 17:53:31 +0800 Subject: [PATCH] Add API to get expire for RedisKey --- src/key.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/key.rs b/src/key.rs index c4f1c143..5c972e58 100644 --- a/src/key.rs +++ b/src/key.rs @@ -111,6 +111,22 @@ impl RedisKey { unsafe { raw::RedisModule_KeyType.unwrap()(self.key_inner) }.into() } + /// # Panics + /// + /// Will panic if `RedisModule_GetExpire` is missing in redismodule.h + #[must_use] + pub fn get_expire(&self) -> i64 { + unsafe { raw::RedisModule_GetExpire.unwrap()(self.key_inner) } + } + + /// # Panics + /// + /// Will panic if `RedisModule_GetAbsExpire` is missing in redismodule.h + #[must_use] + pub fn get_abs_expire(&self) -> i64 { + unsafe { raw::RedisModule_GetAbsExpire.unwrap()(self.key_inner) } + } + /// Detects whether the key pointer given to us by Redis is null. #[must_use] pub fn is_null(&self) -> bool {