优化推流鉴权信息的Redis缓存策略
parent
03090c7260
commit
fe3f4f029e
|
@ -239,31 +239,33 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) {
|
public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) {
|
||||||
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream;
|
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
|
||||||
redisTemplate.opsForValue().set(key, streamAuthorityInfo);
|
String objectKey = app+ "_" + stream;
|
||||||
|
redisTemplate.opsForHash().put(key, objectKey, streamAuthorityInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeStreamAuthorityInfo(String app, String stream) {
|
public void removeStreamAuthorityInfo(String app, String stream) {
|
||||||
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ;
|
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
|
||||||
redisTemplate.delete(key);
|
String objectKey = app+ "_" + stream;
|
||||||
|
redisTemplate.opsForHash().delete(key, objectKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) {
|
public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) {
|
||||||
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ;
|
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
|
||||||
return JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class);
|
String objectKey = app+ "_" + stream;
|
||||||
|
return (StreamAuthorityInfo)redisTemplate.opsForHash().get(key, objectKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StreamAuthorityInfo> getAllStreamAuthorityInfo() {
|
public List<StreamAuthorityInfo> getAllStreamAuthorityInfo() {
|
||||||
String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ;
|
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
|
||||||
List<StreamAuthorityInfo> result = new ArrayList<>();
|
List<StreamAuthorityInfo> result = new ArrayList<>();
|
||||||
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
|
List<Object> values = redisTemplate.opsForHash().values(key);
|
||||||
for (Object o : keys) {
|
for (Object value : values) {
|
||||||
String key = (String) o;
|
result.add((StreamAuthorityInfo)value);
|
||||||
result.add(JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue