修复redis查询
parent
d4fdea3df9
commit
fb8a5d483b
|
@ -70,7 +70,7 @@ public class VideoStreamSessionManager {
|
||||||
stream ="*";
|
stream ="*";
|
||||||
}
|
}
|
||||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||||
List<Object> scanResult = RedisUtil.scan(key, 1);
|
List<Object> scanResult = RedisUtil.scan(key);
|
||||||
if (scanResult.size() == 0) {
|
if (scanResult.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
@Override
|
@Override
|
||||||
public void resetAllSN() {
|
public void resetAllSN() {
|
||||||
String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*";
|
String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*";
|
||||||
List<Object> keys = RedisUtil.scan(scanKey, null);
|
List<Object> keys = RedisUtil.scan(scanKey);
|
||||||
for (Object o : keys) {
|
for (Object o : keys) {
|
||||||
String key = (String) o;
|
String key = (String) o;
|
||||||
RedisUtil.set(key, 1);
|
RedisUtil.set(key, 1);
|
||||||
|
@ -129,7 +129,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo queryPlayByStreamId(String streamId) {
|
public StreamInfo queryPlayByStreamId(String streamId) {
|
||||||
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId), 1);
|
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||||
if (playLeys == null || playLeys.size() == 0) {
|
if (playLeys == null || playLeys.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
||||||
userSetting.getServerId(),
|
userSetting.getServerId(),
|
||||||
deviceId,
|
deviceId,
|
||||||
channelId), 1);
|
channelId));
|
||||||
if (playLeys == null || playLeys.size() == 0) {
|
if (playLeys == null || playLeys.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
stream,
|
stream,
|
||||||
callId
|
callId
|
||||||
);
|
);
|
||||||
List<Object> streamInfoScan = RedisUtil.scan(key, 1);
|
List<Object> streamInfoScan = RedisUtil.scan(key);
|
||||||
if (streamInfoScan.size() > 0) {
|
if (streamInfoScan.size() > 0) {
|
||||||
return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
|
return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
|
||||||
}else {
|
}else {
|
||||||
|
@ -310,7 +310,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
stream,
|
stream,
|
||||||
callId
|
callId
|
||||||
);
|
);
|
||||||
List<Object> streamInfoScan = RedisUtil.scan(key, 1);
|
List<Object> streamInfoScan = RedisUtil.scan(key);
|
||||||
return (String) streamInfoScan.get(0);
|
return (String) streamInfoScan.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
+ channelId + "_"
|
+ channelId + "_"
|
||||||
+ streamId + "_"
|
+ streamId + "_"
|
||||||
+ callId;
|
+ callId;
|
||||||
List<Object> scan = RedisUtil.scan(key, 1);
|
List<Object> scan = RedisUtil.scan(key);
|
||||||
if (scan.size() > 0) {
|
if (scan.size() > 0) {
|
||||||
return (SendRtpItem)RedisUtil.get((String)scan.get(0));
|
return (SendRtpItem)RedisUtil.get((String)scan.get(0));
|
||||||
}else {
|
}else {
|
||||||
|
@ -521,7 +521,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
|
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
|
||||||
+ userSetting.getServerId() + "_*_*_"
|
+ userSetting.getServerId() + "_*_*_"
|
||||||
+ channelId + "*_" + "*_";
|
+ channelId + "*_" + "*_";
|
||||||
List<Object> RtpStreams = RedisUtil.scan(key, 1);
|
List<Object> RtpStreams = RedisUtil.scan(key);
|
||||||
if (RtpStreams.size() > 0) {
|
if (RtpStreams.size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -613,7 +613,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
stream,
|
stream,
|
||||||
callId
|
callId
|
||||||
);
|
);
|
||||||
List<Object> streamInfoScan = RedisUtil.scan(key, 1);
|
List<Object> streamInfoScan = RedisUtil.scan(key);
|
||||||
if (streamInfoScan.size() > 0) {
|
if (streamInfoScan.size() > 0) {
|
||||||
return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
|
return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
|
||||||
}else {
|
}else {
|
||||||
|
@ -732,7 +732,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
|
String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
|
||||||
|
|
||||||
OnStreamChangedHookParam result = null;
|
OnStreamChangedHookParam result = null;
|
||||||
List<Object> keys = RedisUtil.scan(scanKey, 1);
|
List<Object> keys = RedisUtil.scan(scanKey);
|
||||||
if (keys.size() > 0) {
|
if (keys.size() > 0) {
|
||||||
String key = (String) keys.get(0);
|
String key = (String) keys.get(0);
|
||||||
result = (OnStreamChangedHookParam)RedisUtil.get(key);
|
result = (OnStreamChangedHookParam)RedisUtil.get(key);
|
||||||
|
|
|
@ -864,16 +864,12 @@ public class RedisUtil {
|
||||||
* @param query 查询参数
|
* @param query 查询参数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<Object> scan(String query, Integer count) {
|
public static List<Object> scan(String query) {
|
||||||
if (redisTemplate == null) {
|
if (redisTemplate == null) {
|
||||||
redisTemplate = SpringBeanFactory.getBean("redisTemplate");
|
redisTemplate = SpringBeanFactory.getBean("redisTemplate");
|
||||||
}
|
}
|
||||||
Set<String> resultKeys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
|
Set<String> resultKeys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
|
||||||
ScanOptions.ScanOptionsBuilder match = ScanOptions.scanOptions().match("*" + query + "*");
|
ScanOptions scanOptions = ScanOptions.scanOptions().match("*" + query + "*").count(1000).build();
|
||||||
if (count != null) {
|
|
||||||
match.count(count);
|
|
||||||
}
|
|
||||||
ScanOptions scanOptions = match.build();
|
|
||||||
Cursor<byte[]> scan = connection.scan(scanOptions);
|
Cursor<byte[]> scan = connection.scan(scanOptions);
|
||||||
Set<String> keys = new HashSet<>();
|
Set<String> keys = new HashSet<>();
|
||||||
while (scan.hasNext()) {
|
while (scan.hasNext()) {
|
||||||
|
@ -886,15 +882,6 @@ public class RedisUtil {
|
||||||
return new ArrayList<>(resultKeys);
|
return new ArrayList<>(resultKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 模糊查询
|
|
||||||
* @param query 查询参数
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<Object> scan(String query) {
|
|
||||||
return scan(query, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================== 消息发送与订阅 ==============================
|
// ============================== 消息发送与订阅 ==============================
|
||||||
public static void convertAndSend(String channel, JSONObject msg) {
|
public static void convertAndSend(String channel, JSONObject msg) {
|
||||||
if (redisTemplate == null) {
|
if (redisTemplate == null) {
|
||||||
|
|
Loading…
Reference in New Issue