Redis添加获取key的过期时间
This commit is contained in:
@@ -248,6 +248,20 @@ public class RedisService implements BaseParams {
|
|||||||
return stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
|
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 过期时间的设置
|
* 取消对 Key 过期时间的设置
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user