更新README

This commit is contained in:
648540858
2023-01-10 16:26:52 +08:00
parent 72a1f12208
commit 4babf2b47b
10 changed files with 85 additions and 114 deletions

View File

@@ -70,7 +70,7 @@ public class VideoStreamSessionManager {
stream ="*";
}
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
List<Object> scanResult = RedisUtil.scan(key);
List<Object> scanResult = RedisUtil.scan(key, 1);
if (scanResult.size() == 0) {
return null;
}

View File

@@ -75,7 +75,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void resetAllSN() {
String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*";
List<Object> keys = RedisUtil.scan(scanKey);
List<Object> keys = RedisUtil.scan(scanKey, null);
for (Object o : keys) {
String key = (String) o;
RedisUtil.set(key, 1);
@@ -129,7 +129,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
}
@Override
public StreamInfo queryPlayByStreamId(String streamId) {
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId), 1);
if (playLeys == null || playLeys.size() == 0) {
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,
userSetting.getServerId(),
deviceId,
channelId));
channelId), 1);
if (playLeys == null || playLeys.size() == 0) {
return null;
}
@@ -278,7 +278,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
stream,
callId
);
List<Object> streamInfoScan = RedisUtil.scan(key);
List<Object> streamInfoScan = RedisUtil.scan(key, 1);
if (streamInfoScan.size() > 0) {
return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
}else {
@@ -310,7 +310,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
stream,
callId
);
List<Object> streamInfoScan = RedisUtil.scan(key);
List<Object> streamInfoScan = RedisUtil.scan(key, 1);
return (String) streamInfoScan.get(0);
}
@@ -399,7 +399,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
+ channelId + "_"
+ streamId + "_"
+ callId;
List<Object> scan = RedisUtil.scan(key);
List<Object> scan = RedisUtil.scan(key, 1);
if (scan.size() > 0) {
return (SendRtpItem)RedisUtil.get((String)scan.get(0));
}else {
@@ -521,7 +521,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_*_"
+ channelId + "*_" + "*_";
List<Object> RtpStreams = RedisUtil.scan(key);
List<Object> RtpStreams = RedisUtil.scan(key, 1);
if (RtpStreams.size() > 0) {
return true;
} else {
@@ -613,7 +613,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
stream,
callId
);
List<Object> streamInfoScan = RedisUtil.scan(key);
List<Object> streamInfoScan = RedisUtil.scan(key, 1);
if (streamInfoScan.size() > 0) {
return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0));
}else {
@@ -732,7 +732,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
OnStreamChangedHookParam result = null;
List<Object> keys = RedisUtil.scan(scanKey);
List<Object> keys = RedisUtil.scan(scanKey, 1);
if (keys.size() > 0) {
String key = (String) keys.get(0);
result = (OnStreamChangedHookParam)RedisUtil.get(key);

View File

@@ -1,14 +1,13 @@
package com.genersoft.iot.vmp.utils.redis;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
import gov.nist.javax.sip.stack.UDPMessageChannel;
import org.springframework.data.redis.core.*;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Redis工具类
* @author swwheihei
@@ -865,12 +864,16 @@ public class RedisUtil {
* @param query 查询参数
* @return
*/
public static List<Object> scan(String query) {
public static List<Object> scan(String query, Integer count) {
if (redisTemplate == null) {
redisTemplate = SpringBeanFactory.getBean("redisTemplate");
}
Set<String> resultKeys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
ScanOptions scanOptions = ScanOptions.scanOptions().match("*" + query + "*").count(1000).build();
ScanOptions.ScanOptionsBuilder match = ScanOptions.scanOptions().match("*" + query + "*");
if (count != null) {
match.count(count);
}
ScanOptions scanOptions = match.build();
Cursor<byte[]> scan = connection.scan(scanOptions);
Set<String> keys = new HashSet<>();
while (scan.hasNext()) {
@@ -883,6 +886,15 @@ public class RedisUtil {
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) {
if (redisTemplate == null) {