public List<String> batchGet(List<String> keyList){
List<Object> objects = stringRedisTemplate.executePipelined((RedisCallback<Object>) redisConnection -> {
StringRedisConnection stringRedisConnection = (StringRedisConnection) redisConnection;
for (String key : keyList){
stringRedisConnection.get(key);
}
return null;
});
List<String> collect = objects.stream().map(val -> String.valueOf(val)).collect(Collectors.toList());
return collect;
}
这是我批量获取redis值的方法,现在我还想获取每个值的过期时间,就像redisTemplate.getExpire()
这个方法,我可以在管道中批量获取的时候拿到每个值的过期时间吗?
TTL key
以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)。
PTTL key
单位毫秒
无key返回 -2
没设定有效时间返回 -1
详见 http://doc.redisfans.com/key/...