拆分redis中device与channel的存储方式

支持分页
接口直接返回播放地址
This commit is contained in:
648540858
2020-09-25 17:22:22 +08:00
parent 956fd47ed6
commit da14c7f24c
21 changed files with 1445 additions and 78 deletions

View File

@@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -389,6 +390,121 @@ public class RedisUtil {
return 0;
}
}
// ============================== ZSet ==============================
/**
* 添加一个元素, zset与set最大的区别就是每个元素都有一个score因此有个排序的辅助功能; zadd
*
* @param key
* @param value
* @param score
*/
public void zAdd(String key, String value, double score) {
redisTemplate.opsForZSet().add(key, value, score);
}
/**
* 删除元素 zrem
*
* @param key
* @param value
*/
public void zRemove(String key, String value) {
redisTemplate.opsForZSet().remove(key, value);
}
/**
* score的增加or减少 zincrby
*
* @param key
* @param value
* @param score
*/
public Double zIncrScore(String key, String value, double score) {
return redisTemplate.opsForZSet().incrementScore(key, value, score);
}
/**
* 查询value对应的score zscore
*
* @param key
* @param value
* @return
*/
public Double zScore(String key, String value) {
return redisTemplate.opsForZSet().score(key, value);
}
/**
* 判断value在zset中的排名 zrank
*
* @param key
* @param value
* @return
*/
public Long zRank(String key, String value) {
return redisTemplate.opsForZSet().rank(key, value);
}
/**
* 返回集合的长度
*
* @param key
* @return
*/
public Long zSize(String key) {
return redisTemplate.opsForZSet().zCard(key);
}
/**
* 查询集合中指定顺序的值, 0 -1 表示获取全部的集合内容 zrange
*
* 返回有序的集合score小的在前面
*
* @param key
* @param start
* @param end
* @return
*/
public Set<String> ZRange(String key, int start, int end) {
return redisTemplate.opsForZSet().range(key, start, end);
}
/**
* 查询集合中指定顺序的值和score0, -1 表示获取全部的集合内容
*
* @param key
* @param start
* @param end
* @return
*/
public Set<ZSetOperations.TypedTuple<String>> zRangeWithScore(String key, int start, int end) {
return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
}
/**
* 查询集合中指定顺序的值 zrevrange
*
* 返回有序的集合中score大的在前面
*
* @param key
* @param start
* @param end
* @return
*/
public Set<String> zRevRange(String key, int start, int end) {
return redisTemplate.opsForZSet().reverseRange(key, start, end);
}
/**
* 根据score的值来获取满足条件的集合 zrangebyscore
*
* @param key
* @param min
* @param max
* @return
*/
public Set<String> zSortRange(String key, int min, int max) {
return redisTemplate.opsForZSet().rangeByScore(key, min, max);
}
// ============================== List ==============================