feta(RDMP-5834) keys命令异常抛出

This commit is contained in:
TanJ 2025-10-15 10:09:45 +08:00
parent dc11b8c994
commit 93acbd775e

View File

@ -455,31 +455,39 @@ public class RedisUtils {
/**
* 获得缓存的基本对象列表
* 禁止使用会导致Redis阻塞
*
* @param pattern 字符串前缀
* @return 对象列表
*/
@Deprecated
public static Collection<String> keys(final String pattern) {
Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
return stream.collect(Collectors.toList());
// Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
// return stream.collect(Collectors.toList());
throw new UnsupportedOperationException("禁止使用keys命令,请使用scan");
}
/**
* 删除缓存的基本对象列表
*
* @param pattern 字符串前缀
* 禁止使用会导致Redis阻塞
*/
@Deprecated
public static void deleteKeys(final String pattern) {
CLIENT.getKeys().deleteByPattern(pattern);
// CLIENT.getKeys().deleteByPattern(pattern);
throw new UnsupportedOperationException("禁止使用keys命令,请使用scan");
}
/**
* 检查redis中是否存在key
*
* 禁止使用会导致Redis阻塞
* @param key
*/
@Deprecated
public static Boolean hasKey(String key) {
RKeys rKeys = CLIENT.getKeys();
return rKeys.countExists(key) > 0;
// RKeys rKeys = CLIENT.getKeys();
// return rKeys.countExists(key) > 0;
throw new UnsupportedOperationException("禁止使用keys命令,请使用scan");
}
}