Commit 8a68bae0bb02127cc62c07bf8727af4b88df0981

Authored by 648540858
1 parent cb897aae

修复redis数据写入时超时时间设置错误的问题

src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -27,6 +27,7 @@ import org.springframework.data.redis.core.RedisTemplate; @@ -27,6 +27,7 @@ import org.springframework.data.redis.core.RedisTemplate;
27 import org.springframework.data.redis.core.StringRedisTemplate; 27 import org.springframework.data.redis.core.StringRedisTemplate;
28 import org.springframework.stereotype.Component; 28 import org.springframework.stereotype.Component;
29 29
  30 +import java.time.Duration;
30 import java.util.*; 31 import java.util.*;
31 32
32 @SuppressWarnings("rawtypes") 33 @SuppressWarnings("rawtypes")
@@ -189,7 +190,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -189,7 +190,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
189 redisTemplate.opsForValue().set(key, stream); 190 redisTemplate.opsForValue().set(key, stream);
190 }else { 191 }else {
191 logger.debug("添加下载缓存==未完成下载=》{}",key); 192 logger.debug("添加下载缓存==未完成下载=》{}",key);
192 - redisTemplate.opsForValue().set(key, stream, 60*60); 193 + Duration duration = Duration.ofSeconds(60*60L);
  194 + redisTemplate.opsForValue().set(key, stream, duration);
193 } 195 }
194 return true; 196 return true;
195 } 197 }
@@ -355,7 +357,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -355,7 +357,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
355 @Override 357 @Override
356 public void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo) { 358 public void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo) {
357 String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId; 359 String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId;
358 - redisTemplate.opsForValue().set(key, platformRegisterInfo, 30); 360 + Duration duration = Duration.ofSeconds(30L);
  361 + redisTemplate.opsForValue().set(key, platformRegisterInfo, duration);
359 } 362 }
360 363
361 364
@@ -566,7 +569,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -566,7 +569,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
566 @Override 569 @Override
567 public void updateWVPInfo(JSONObject jsonObject, int time) { 570 public void updateWVPInfo(JSONObject jsonObject, int time) {
568 String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId(); 571 String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId();
569 - redisTemplate.opsForValue().set(key, jsonObject, time); 572 + Duration duration = Duration.ofSeconds(time);
  573 + redisTemplate.opsForValue().set(key, jsonObject, duration);
570 } 574 }
571 575
572 @Override 576 @Override
@@ -698,7 +702,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -698,7 +702,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
698 @Override 702 @Override
699 public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) { 703 public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) {
700 String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId(); 704 String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId();
701 - redisTemplate.opsForValue().set(key, gpsMsgInfo, 60); // 默认GPS消息保存1分钟 705 + Duration duration = Duration.ofSeconds(60L);
  706 + redisTemplate.opsForValue().set(key, gpsMsgInfo, duration); // 默认GPS消息保存1分钟
702 } 707 }
703 708
704 @Override 709 @Override