diff --git a/src/main/java/org/springframework/data/redis/core/RedisOperations.java b/src/main/java/org/springframework/data/redis/core/RedisOperations.java index 4ea682d900..cadfa9c2de 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisOperations.java +++ b/src/main/java/org/springframework/data/redis/core/RedisOperations.java @@ -262,11 +262,14 @@ T execute(RedisScript script, RedisSerializer argsSerializer, RedisSer DataType type(K key); /** - * Find all keys matching the given {@code pattern}. - * - * @param pattern must not be {@literal null}. - * @return {@literal null} when used in pipeline / transaction. - * @see Redis Documentation: KEYS + * Retrieve keys matching the given pattern via {@code KEYS} command. + *

+ * Note: This command scans the entire keyspace and may cause performance issues + * in production environments. Prefer using {@link #scan(ScanOptions)} for large datasets. + * + * @param pattern key pattern + * @return set of matching keys, or {@literal null} when used in pipeline / transaction + * @see Redis KEYS command */ @Nullable Set keys(K pattern); diff --git a/src/main/java/org/springframework/data/redis/core/RedisTemplate.java b/src/main/java/org/springframework/data/redis/core/RedisTemplate.java index c80f555ee0..d12680b54b 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisTemplate.java +++ b/src/main/java/org/springframework/data/redis/core/RedisTemplate.java @@ -637,6 +637,16 @@ public DataType type(K key) { return doWithKeys(connection -> connection.type(rawKey)); } + /** + * Retrieve keys matching the given pattern via {@code KEYS} command. + *

+ * Note: This command scans the entire keyspace and may cause performance issues + * in production environments. Prefer using {@link #scan(ScanOptions)} for large datasets. + * + * @param pattern key pattern + * @return set of matching keys + * @see Redis KEYS command + */ @Override @SuppressWarnings("unchecked") public Set keys(K pattern) {