From 8a68bae0bb02127cc62c07bf8727af4b88df0981 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 27 Apr 2023 09:23:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dredis=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=97=B6=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/storager/impl/RedisCatchStorageImpl.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 4c681e88..d4abcb45 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -27,6 +27,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; +import java.time.Duration; import java.util.*; @SuppressWarnings("rawtypes") @@ -189,7 +190,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { redisTemplate.opsForValue().set(key, stream); }else { logger.debug("添加下载缓存==未完成下载=》{}",key); - redisTemplate.opsForValue().set(key, stream, 60*60); + Duration duration = Duration.ofSeconds(60*60L); + redisTemplate.opsForValue().set(key, stream, duration); } return true; } @@ -355,7 +357,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo) { String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId; - redisTemplate.opsForValue().set(key, platformRegisterInfo, 30); + Duration duration = Duration.ofSeconds(30L); + redisTemplate.opsForValue().set(key, platformRegisterInfo, duration); } @@ -566,7 +569,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void updateWVPInfo(JSONObject jsonObject, int time) { String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId(); - redisTemplate.opsForValue().set(key, jsonObject, time); + Duration duration = Duration.ofSeconds(time); + redisTemplate.opsForValue().set(key, jsonObject, duration); } @Override @@ -698,7 +702,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) { String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId(); - redisTemplate.opsForValue().set(key, gpsMsgInfo, 60); // 默认GPS消息保存1分钟 + Duration duration = Duration.ofSeconds(60L); + redisTemplate.opsForValue().set(key, gpsMsgInfo, duration); // 默认GPS消息保存1分钟 } @Override