Skip to content

Add performance warning to RedisTemplate#keys() and RedisOperations#keys() Javadoc #3142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,14 @@ <T> T execute(RedisScript<T> 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 <a href="https://redis.io/commands/keys">Redis Documentation: KEYS</a>
* Retrieve keys matching the given pattern via {@code KEYS} command.
* <p>
* 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 <a href="https://redis.io/commands/keys">Redis KEYS command</a>
*/
@Nullable
Set<K> keys(K pattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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 <a href="https://redis.io/commands/keys">Redis KEYS command</a>
*/
@Override
@SuppressWarnings("unchecked")
public Set<K> keys(K pattern) {
Expand Down