spring-projects / spring-projects/spring-data-redis
lettuce connection.execute("JSON.MGET", args) not working as expected
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
When we do
List<byte[]> argList = new ArrayList<>();
for (String key : keys) {
argList.add(key.getBytes(UTF_8));
}
argList.add(".".getBytes(UTF_8));
byte[][] args = argList.toArray(new byte[0][]);
var result = connection.execute("JSON.MGET", args);
we get a Json array with one element, the result from the last key.
We expect results for all keys.
run the test should return more than the last key to show the problem
see lettuce Issue here - the problem was already analyzed from lettuce side and found to be within SDR:
"it's not actually a Lettuce problem ...
Currently spring-data-redis doesn't have native JSON API, so you are forced to use the RAW command API. spring-data-redis doesn't allow you to choose the output type for yourself, but makes the choice on your behalf. And in the current scenario - makes wrong choice - ByteArrayOutput, which as you already found returns you only one of the keys.
TLDR - you should raise this issue to SDR and from what i saw it should be easy solution for them - to fix the mapping for JSON MGET to some sort of ListOutput - currently in Lettuce we use JsonValueListOutput."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided demo and the should return more than the last key test, then trace how connection.execute("JSON.MGET", args) maps its output in Spring Data Redis. Done means JSON.MGET returns one result for each requested key rather than only the last key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis, spring
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100