update 部分接口新增返回算力单位
This commit is contained in:
@@ -310,7 +310,26 @@ public class RedisService {
|
||||
*/
|
||||
public <T> void deleteCacheMapValue7(final Map<String, String> keyFieldMap) {
|
||||
keyFieldMap.forEach((key, hKey) -> {
|
||||
redisTemplate7.opsForHash().delete(key, hKey);
|
||||
try {
|
||||
// 先判断 key 是否存在
|
||||
if (redisTemplate7.hasKey(key)) {
|
||||
// 检查 key 的类型是否为 Hash
|
||||
org.springframework.data.redis.core.DataType dataType = redisTemplate7.type(key);
|
||||
if (dataType == org.springframework.data.redis.core.DataType.HASH) {
|
||||
// 再判断 hKey 是否存在
|
||||
if (redisTemplate7.opsForHash().hasKey(key, hKey)) {
|
||||
redisTemplate7.opsForHash().delete(key, hKey);
|
||||
}
|
||||
} else {
|
||||
System.out.println(String.format("警告: key %s 存在但类型为 %s,不是 Hash 类型,跳过删除 hKey %s",
|
||||
key, dataType, hKey));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(String.format("删除 Redis Hash 数据时出错: key=%s, hKey=%s, error=%s",
|
||||
key, hKey, e.getMessage()));
|
||||
// 不抛出异常,继续处理下一个
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user