1
0

设备历史轨迹

This commit is contained in:
2025-08-02 09:09:02 +08:00
parent c8dff1a082
commit ce8f6c9a77
4 changed files with 65 additions and 4 deletions

View File

@ -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数据
*