redisutil加异常捕捉和日志

back_recharge
duhui 2022-10-20 10:34:21 +08:00
parent e89efa1a76
commit c2940417ad
1 changed files with 28 additions and 18 deletions

View File

@ -155,6 +155,7 @@ public class RedisUtil {
*/
@SuppressWarnings("unchecked")
public void del(String... key) {
try {
if (key != null && key.length > 0) {
if (key.length == 1) {
redisTemplate.delete(key[0]);
@ -162,6 +163,9 @@ public class RedisUtil {
redisTemplate.delete(CollectionUtils.arrayToList(key));
}
}
}catch (Exception e){
LOGGER.error("redis删除key失败,key{},error:{}",key,e.getMessage());
}
}
/**
@ -195,6 +199,7 @@ public class RedisUtil {
* @param key
*/
public void rename(long time,String postfix,String[] key) {
try {
if (key != null && key.length > 0) {
for (int i = 0; i < key.length; i++) {
// 旧名字
@ -210,7 +215,12 @@ public class RedisUtil {
expire(newName,time);
}
}
return;
}
}catch (Exception e){
LOGGER.error("redis重命名key失败,key{},error:{}",key,e.getMessage());
}
del(key);
}
// ============================String=============================