使用冒号分隔redis的key

pull/1400/head
648540858 2024-03-28 18:08:33 +08:00
parent f1e902af7f
commit 1de344674a
1 changed files with 9 additions and 9 deletions

View File

@ -50,7 +50,7 @@ public class VideoStreamSessionManager {
ssrcTransaction.setType(type); ssrcTransaction.setType(type);
redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
+ "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); + ":" + deviceId + ":" + channelId + ":" + callId + ":" + stream, ssrcTransaction);
} }
public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
@ -67,7 +67,7 @@ public class VideoStreamSessionManager {
if (ObjectUtils.isEmpty(stream)) { if (ObjectUtils.isEmpty(stream)) {
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(redisTemplate, key); List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
if (scanResult.size() == 0) { if (scanResult.size() == 0) {
return null; return null;
@ -80,12 +80,12 @@ public class VideoStreamSessionManager {
if (ObjectUtils.isEmpty(callId)) { if (ObjectUtils.isEmpty(callId)) {
return null; return null;
} }
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_*_*_" + callId+ "_*"; String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + ":*:*:" + callId+ ":*";
List<Object> scanResult = RedisUtil.scan(redisTemplate, key); List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
if (!scanResult.isEmpty()) { if (!scanResult.isEmpty()) {
return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0)); return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0));
}else { }else {
key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_*_*_play_*"; key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + ":*:*:play:*";
scanResult = RedisUtil.scan(redisTemplate, key); scanResult = RedisUtil.scan(redisTemplate, key);
if (scanResult.isEmpty()) { if (scanResult.isEmpty()) {
return null; return null;
@ -115,7 +115,7 @@ public class VideoStreamSessionManager {
if (ObjectUtils.isEmpty(stream)) { if (ObjectUtils.isEmpty(stream)) {
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(redisTemplate, key); List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
if (scanResult.size() == 0) { if (scanResult.size() == 0) {
return null; return null;
@ -149,8 +149,8 @@ public class VideoStreamSessionManager {
return; return;
} }
for (SsrcTransaction ssrcTransaction : ssrcTransactionList) { for (SsrcTransaction ssrcTransaction : ssrcTransactionList) {
redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + ":"
+ deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream()); + deviceId + ":" + channelId + ":" + ssrcTransaction.getCallId() + ":" + ssrcTransaction.getStream());
} }
} }
@ -159,8 +159,8 @@ public class VideoStreamSessionManager {
if (ssrcTransaction == null ) { if (ssrcTransaction == null ) {
return; return;
} }
redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + ":"
+ deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream()); + deviceId + ":" + channelId + ":" + ssrcTransaction.getCallId() + ":" + ssrcTransaction.getStream());
} }