spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

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

Open wooodypark opened this issue 7 months ago • 2 comments

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

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

References

wooodypark avatar Apr 30 '25 05:04 wooodypark

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

mp911de avatar May 05 '25 13:05 mp911de

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().

wooodypark avatar May 06 '25 10:05 wooodypark

Thank you for your contribution. That's merged, polished, and backported now.

mp911de avatar Jul 10 '25 07:07 mp911de