Redis添加获取key的过期时间

This commit is contained in:
2026-06-04 17:29:05 +08:00
parent 1115b60d78
commit a516b9b043

View File

@@ -248,6 +248,20 @@ public class RedisService implements BaseParams {
return stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
}
/**
* 获取key的过期时间(秒)
*
* @param key Key
* @return 过期时间(秒)
*/
public Long getExpire(String key) {
// 参数校验
if (StringUtils.isEmpty(key)) {
return null;
}
return stringRedisTemplate.getExpire(key);
}
/**
* 取消对 Key 过期时间的设置
*