Commit fb8a5d483bcaad8d0c4a9ac5842291eef694eb05

Authored by 648540858
1 parent d4fdea3d

修复redis查询

src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
... ... @@ -70,7 +70,7 @@ public class VideoStreamSessionManager {
70 70 stream ="*";
71 71 }
72 72 String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
73   - List<Object> scanResult = RedisUtil.scan(key, 1);
  73 + List<Object> scanResult = RedisUtil.scan(key);
74 74 if (scanResult.size() == 0) {
75 75 return null;
76 76 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
... ... @@ -75,7 +75,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
75 75 @Override
76 76 public void resetAllSN() {
77 77 String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*";
78   - List<Object> keys = RedisUtil.scan(scanKey, null);
  78 + List<Object> keys = RedisUtil.scan(scanKey);
79 79 for (Object o : keys) {
80 80 String key = (String) o;
81 81 RedisUtil.set(key, 1);
... ... @@ -129,7 +129,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
129 129 }
130 130 @Override
131 131 public StreamInfo queryPlayByStreamId(String streamId) {
132   - List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId), 1);
  132 + List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
133 133 if (playLeys == null || playLeys.size() == 0) {
134 134 return null;
135 135 }
... ... @@ -141,7 +141,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
141 141 List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
142 142 userSetting.getServerId(),
143 143 deviceId,
144   - channelId), 1);
  144 + channelId));
145 145 if (playLeys == null || playLeys.size() == 0) {
146 146 return null;
147 147 }
... ... @@ -278,7 +278,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
278 278 stream,
279 279 callId
280 280 );
281   - List<Object> streamInfoScan = RedisUtil.scan(key, 1);
  281 + List<Object> streamInfoScan = RedisUtil.scan(key);
282 282 if (streamInfoScan.size() > 0) {
283 283 return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
284 284 }else {
... ... @@ -310,7 +310,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
310 310 stream,
311 311 callId
312 312 );
313   - List<Object> streamInfoScan = RedisUtil.scan(key, 1);
  313 + List<Object> streamInfoScan = RedisUtil.scan(key);
314 314 return (String) streamInfoScan.get(0);
315 315 }
316 316  
... ... @@ -399,7 +399,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
399 399 + channelId + "_"
400 400 + streamId + "_"
401 401 + callId;
402   - List<Object> scan = RedisUtil.scan(key, 1);
  402 + List<Object> scan = RedisUtil.scan(key);
403 403 if (scan.size() > 0) {
404 404 return (SendRtpItem)RedisUtil.get((String)scan.get(0));
405 405 }else {
... ... @@ -521,7 +521,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
521 521 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
522 522 + userSetting.getServerId() + "_*_*_"
523 523 + channelId + "*_" + "*_";
524   - List<Object> RtpStreams = RedisUtil.scan(key, 1);
  524 + List<Object> RtpStreams = RedisUtil.scan(key);
525 525 if (RtpStreams.size() > 0) {
526 526 return true;
527 527 } else {
... ... @@ -613,7 +613,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
613 613 stream,
614 614 callId
615 615 );
616   - List<Object> streamInfoScan = RedisUtil.scan(key, 1);
  616 + List<Object> streamInfoScan = RedisUtil.scan(key);
617 617 if (streamInfoScan.size() > 0) {
618 618 return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
619 619 }else {
... ... @@ -732,7 +732,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
732 732 String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
733 733  
734 734 OnStreamChangedHookParam result = null;
735   - List<Object> keys = RedisUtil.scan(scanKey, 1);
  735 + List<Object> keys = RedisUtil.scan(scanKey);
736 736 if (keys.size() > 0) {
737 737 String key = (String) keys.get(0);
738 738 result = (OnStreamChangedHookParam)RedisUtil.get(key);
... ...
src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
... ... @@ -864,16 +864,12 @@ public class RedisUtil {
864 864 * @param query 查询参数
865 865 * @return
866 866 */
867   - public static List<Object> scan(String query, Integer count) {
  867 + public static List<Object> scan(String query) {
868 868 if (redisTemplate == null) {
869 869 redisTemplate = SpringBeanFactory.getBean("redisTemplate");
870 870 }
871 871 Set<String> resultKeys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
872   - ScanOptions.ScanOptionsBuilder match = ScanOptions.scanOptions().match("*" + query + "*");
873   - if (count != null) {
874   - match.count(count);
875   - }
876   - ScanOptions scanOptions = match.build();
  872 + ScanOptions scanOptions = ScanOptions.scanOptions().match("*" + query + "*").count(1000).build();
877 873 Cursor<byte[]> scan = connection.scan(scanOptions);
878 874 Set<String> keys = new HashSet<>();
879 875 while (scan.hasNext()) {
... ... @@ -886,15 +882,6 @@ public class RedisUtil {
886 882 return new ArrayList<>(resultKeys);
887 883 }
888 884  
889   - /**
890   - * 模糊查询
891   - * @param query 查询参数
892   - * @return
893   - */
894   - public static List<Object> scan(String query) {
895   - return scan(query, null);
896   - }
897   -
898 885 // ============================== 消息发送与订阅 ==============================
899 886 public static void convertAndSend(String channel, JSONObject msg) {
900 887 if (redisTemplate == null) {
... ...