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,7 +70,7 @@ public class VideoStreamSessionManager {
70 stream ="*"; 70 stream ="*";
71 } 71 }
72 String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; 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 if (scanResult.size() == 0) { 74 if (scanResult.size() == 0) {
75 return null; 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,7 +75,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
75 @Override 75 @Override
76 public void resetAllSN() { 76 public void resetAllSN() {
77 String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*"; 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 for (Object o : keys) { 79 for (Object o : keys) {
80 String key = (String) o; 80 String key = (String) o;
81 RedisUtil.set(key, 1); 81 RedisUtil.set(key, 1);
@@ -129,7 +129,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -129,7 +129,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
129 } 129 }
130 @Override 130 @Override
131 public StreamInfo queryPlayByStreamId(String streamId) { 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 if (playLeys == null || playLeys.size() == 0) { 133 if (playLeys == null || playLeys.size() == 0) {
134 return null; 134 return null;
135 } 135 }
@@ -141,7 +141,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -141,7 +141,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
141 List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, 141 List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
142 userSetting.getServerId(), 142 userSetting.getServerId(),
143 deviceId, 143 deviceId,
144 - channelId), 1); 144 + channelId));
145 if (playLeys == null || playLeys.size() == 0) { 145 if (playLeys == null || playLeys.size() == 0) {
146 return null; 146 return null;
147 } 147 }
@@ -278,7 +278,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -278,7 +278,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
278 stream, 278 stream,
279 callId 279 callId
280 ); 280 );
281 - List<Object> streamInfoScan = RedisUtil.scan(key, 1); 281 + List<Object> streamInfoScan = RedisUtil.scan(key);
282 if (streamInfoScan.size() > 0) { 282 if (streamInfoScan.size() > 0) {
283 return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0)); 283 return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
284 }else { 284 }else {
@@ -310,7 +310,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -310,7 +310,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
310 stream, 310 stream,
311 callId 311 callId
312 ); 312 );
313 - List<Object> streamInfoScan = RedisUtil.scan(key, 1); 313 + List<Object> streamInfoScan = RedisUtil.scan(key);
314 return (String) streamInfoScan.get(0); 314 return (String) streamInfoScan.get(0);
315 } 315 }
316 316
@@ -399,7 +399,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -399,7 +399,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
399 + channelId + "_" 399 + channelId + "_"
400 + streamId + "_" 400 + streamId + "_"
401 + callId; 401 + callId;
402 - List<Object> scan = RedisUtil.scan(key, 1); 402 + List<Object> scan = RedisUtil.scan(key);
403 if (scan.size() > 0) { 403 if (scan.size() > 0) {
404 return (SendRtpItem)RedisUtil.get((String)scan.get(0)); 404 return (SendRtpItem)RedisUtil.get((String)scan.get(0));
405 }else { 405 }else {
@@ -521,7 +521,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -521,7 +521,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
521 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX 521 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
522 + userSetting.getServerId() + "_*_*_" 522 + userSetting.getServerId() + "_*_*_"
523 + channelId + "*_" + "*_"; 523 + channelId + "*_" + "*_";
524 - List<Object> RtpStreams = RedisUtil.scan(key, 1); 524 + List<Object> RtpStreams = RedisUtil.scan(key);
525 if (RtpStreams.size() > 0) { 525 if (RtpStreams.size() > 0) {
526 return true; 526 return true;
527 } else { 527 } else {
@@ -613,7 +613,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -613,7 +613,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
613 stream, 613 stream,
614 callId 614 callId
615 ); 615 );
616 - List<Object> streamInfoScan = RedisUtil.scan(key, 1); 616 + List<Object> streamInfoScan = RedisUtil.scan(key);
617 if (streamInfoScan.size() > 0) { 617 if (streamInfoScan.size() > 0) {
618 return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0)); 618 return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
619 }else { 619 }else {
@@ -732,7 +732,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -732,7 +732,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
732 String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId; 732 String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
733 733
734 OnStreamChangedHookParam result = null; 734 OnStreamChangedHookParam result = null;
735 - List<Object> keys = RedisUtil.scan(scanKey, 1); 735 + List<Object> keys = RedisUtil.scan(scanKey);
736 if (keys.size() > 0) { 736 if (keys.size() > 0) {
737 String key = (String) keys.get(0); 737 String key = (String) keys.get(0);
738 result = (OnStreamChangedHookParam)RedisUtil.get(key); 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,16 +864,12 @@ public class RedisUtil {
864 * @param query 查询参数 864 * @param query 查询参数
865 * @return 865 * @return
866 */ 866 */
867 - public static List<Object> scan(String query, Integer count) { 867 + public static List<Object> scan(String query) {
868 if (redisTemplate == null) { 868 if (redisTemplate == null) {
869 redisTemplate = SpringBeanFactory.getBean("redisTemplate"); 869 redisTemplate = SpringBeanFactory.getBean("redisTemplate");
870 } 870 }
871 Set<String> resultKeys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> { 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 Cursor<byte[]> scan = connection.scan(scanOptions); 873 Cursor<byte[]> scan = connection.scan(scanOptions);
878 Set<String> keys = new HashSet<>(); 874 Set<String> keys = new HashSet<>();
879 while (scan.hasNext()) { 875 while (scan.hasNext()) {
@@ -886,15 +882,6 @@ public class RedisUtil { @@ -886,15 +882,6 @@ public class RedisUtil {
886 return new ArrayList<>(resultKeys); 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 public static void convertAndSend(String channel, JSONObject msg) { 886 public static void convertAndSend(String channel, JSONObject msg) {
900 if (redisTemplate == null) { 887 if (redisTemplate == null) {