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