From fe3f4f029ef836807f25d09bcb3975cf806ded2e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 27 Oct 2024 21:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A8=E6=B5=81=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E4=BF=A1=E6=81=AF=E7=9A=84Redis=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storager/impl/RedisCatchStorageImpl.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 4d478c44..b5307c44 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -239,31 +239,33 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) { - String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream; - redisTemplate.opsForValue().set(key, streamAuthorityInfo); + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId(); + String objectKey = app+ "_" + stream; + redisTemplate.opsForHash().put(key, objectKey, streamAuthorityInfo); } @Override public void removeStreamAuthorityInfo(String app, String stream) { - String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ; - redisTemplate.delete(key); + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId(); + String objectKey = app+ "_" + stream; + redisTemplate.opsForHash().delete(key, objectKey); } @Override public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) { - String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ; - return JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class); + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId(); + String objectKey = app+ "_" + stream; + return (StreamAuthorityInfo)redisTemplate.opsForHash().get(key, objectKey); } @Override public List getAllStreamAuthorityInfo() { - String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ; + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId(); List result = new ArrayList<>(); - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object o : keys) { - String key = (String) o; - result.add(JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class)); + List values = redisTemplate.opsForHash().values(key); + for (Object value : values) { + result.add((StreamAuthorityInfo)value); } return result; }