设备历史轨迹
This commit is contained in:
@ -339,7 +339,40 @@ public class RedisUtils {
|
||||
RSet<T> rSet = CLIENT.getSet(key);
|
||||
return rSet.addAll(dataSet);
|
||||
}
|
||||
/**
|
||||
* 向Sorted Set添加元素
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param score 分数
|
||||
* @return 添加成功返回true,否则返回false
|
||||
*/
|
||||
public static boolean zAdd(String key, Object value, double score) {
|
||||
try {
|
||||
RScoredSortedSet<Object> sortedSet = CLIENT.getScoredSortedSet(key);
|
||||
return sortedSet.add(score, value);
|
||||
} catch (Exception e) {
|
||||
// log.error("向Sorted Set添加元素失败: key={}, value={}, score={}, error={}", key, value, score, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除Sorted Set中指定范围的元素(按分数)
|
||||
*
|
||||
* @param key 键
|
||||
* @param min 最小分数
|
||||
* @param max 最大分数
|
||||
* @return 移除的元素数量
|
||||
*/
|
||||
public static int zRemoveRangeByScore(String key, double min, double max) {
|
||||
try {
|
||||
RScoredSortedSet<Object> sortedSet = CLIENT.getScoredSortedSet(key);
|
||||
return sortedSet.removeRangeByScore(min, true, max, true);
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 追加缓存Set数据
|
||||
*
|
||||
|
Reference in New Issue
Block a user