Skip to content

Add support for batch lookup by ID. - #696

Open
dlwldnjs1009 wants to merge 4 commits into
spring-projects:mainfrom
dlwldnjs1009:issue/655
Open

dlwldnjs1009 wants to merge 4 commits into
spring-projects:mainfrom
dlwldnjs1009:issue/655

Conversation

@dlwldnjs1009

@dlwldnjs1009 dlwldnjs1009 commented Sep 18, 2026 •

Copy link
Copy Markdown

SimpleKeyValueRepository.findAllById performs one adapter lookup per id, so store modules cannot provide a batch implementation such as the one requested in spring-projects/spring-data-redis#3150.

This change adds KeyValueOperations.findAllById(…) and a KeyValueAdapter.getAll(…) default method that falls back to per-id get(…). getAll returns one element per requested id, in order, with null for missing entries, so the template can pair each id with its result when publishing AfterGetEvent. findAllById skips missing entries.

Event order changes on this path: all BeforeGetEvents are published before the batch lookup, followed by one AfterGetEvent per id, instead of a before/after pair per id.

Tests: KeyValueTemplateUnitTests, KeyValueTemplateTests, SimpleKeyValueRepositoryUnitTests.

Open questions:

  • getAll sits next to getAllOf(keyspace), which returns the entire keyspace. Would getAllById be clearer?
  • KeyValueOperations.findAllById(…) is abstract, following exists(…). Existing implementation binaries that neither implement nor inherit the new method will fail with AbstractMethodError when SimpleKeyValueRepository.findAllById(...) calls it. Dapr's DaprKeyValueTemplate is an example of a direct KeyValueOperations implementation. Should we make this a default method that falls back to findById(…)?

Closes #655

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Closes spring-projects#655

Signed-off-by: Lee Jiwon <dlwldnjs1009@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 18, 2026
@dlwldnjs1009
dlwldnjs1009 marked this pull request as ready for review September 18, 2026 07:45
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 28, 2026
@mp911de mp911de self-assigned this Sep 28, 2026
…aces.

See spring-projects#655

Signed-off-by: Lee Jiwon <dlwldnjs1009@gmail.com>
See spring-projects#655

Signed-off-by: Lee Jiwon <dlwldnjs1009@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for KeyValueOperations.findAllById(…)

3 participants