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

Conversation

connorcoco
Copy link

@connorcoco connorcoco commented Apr 30, 2025

Description

This pull request updates the Javadoc of both RedisTemplate#keys() and RedisOperations#keys() methods to include a performance warning regarding the use of the KEYS command.

The KEYS command performs a full scan of the Redis keyspace, which can severely impact performance in production environments.
To avoid misuse, the updated Javadocs include a warning and recommend using scan(ScanOptions) as a safer alternative for large datasets.

  • The warning has been added to:
    • RedisTemplate#keys() implementation method.
    • RedisOperations#keys() interface method.

Note: ReactiveRedisOperations#keys() already contains a similar warning and did not require changes.


Checklist

  • I have read the Spring Data contribution guidelines.
  • I used the code formatters provided here and did not include any formatting-only changes.
  • No test cases were needed as this change is limited to documentation (Javadoc only).
  • No author header update was required since only a Javadoc comment was changed and no logic was modified.

References

@connorcoco connorcoco force-pushed the docs/keys-method-warning branch from 2cd631b to 23d1dd0 Compare April 30, 2025 05:44
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 30, 2025
@mp911de
Copy link
Member

mp911de commented May 5, 2025

Care to move this documentation bit to RedisOperations? And please cross-check ReactiveRedisOperations for the same mention.

@mp911de mp911de added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels May 5, 2025
@connorcoco
Copy link
Author

Care to move this documentation bit to RedisOperations? And please cross-check ReactiveRedisOperations for the same mention.

Thanks for the suggestion!
I reviewed ReactiveRedisOperations#keys() and confirmed it already includes a similar warning about performance concerns and recommends using scan().
Therefore, I only applied the Javadoc update to RedisOperations#keys().

@connorcoco connorcoco changed the title Add performance warning to RedisTemplate.keys() Javadoc Add performance warning to RedisTemplate#keys() and RedisOperations#keys() Javadoc May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants