更新redis的使用和数据汇总性能优化

This commit is contained in:
2026-06-24 13:49:57 +08:00
parent 0b4860f46e
commit 4105b901f1
16 changed files with 662 additions and 119 deletions
@@ -116,4 +116,23 @@ public class RedisUtils {
public Object rightPop(String key) {
return redisTemplate.opsForList().rightPop(key);
}
/**
* 按模式删除缓存
* @param pattern 匹配模式,如 "weather:summarize:*"
*/
public void deleteByPattern(String pattern) {
java.util.Set<String> keys = redisTemplate.keys(pattern);
if (keys != null && !keys.isEmpty()) {
redisTemplate.delete(keys);
}
}
/**
* 判断缓存是否存在
*/
public boolean exists(String key) {
Boolean result = redisTemplate.hasKey(key);
return Boolean.TRUE.equals(result);
}
}