更新redis的使用和数据汇总性能优化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user