redis: maybe write key to state?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24
- Forks
- 41
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 12
Description
In redis, a really common pattern is gonna be something like this
each(
$.data,
jGet($.data).then(state => {
state.results.push(state.data);
return state;
})
);
You iterate over a set of keys, you fetch each item, you transform it and map it to state
But what if you need the key for the item you just fetched? That's been passed to get by each but then been overwritten. If the key doesn't happen to be in data, you've lost it.
The workaround is to fetch it out of references like this:
each(
$.data,
jGet($.data).then(state => {
const key = state.references.at(-1).split(':')[0];
state.results[key].push(state.data);
return state;
})
);
One solution would be for all redis functions to return { key, data }, much like how http returns { response, data }. That would make the key associated with data available downstream.
If there's other metadata we might want to include, perhaps we need a meta or response to be added to state instead.
Contributor guide
No contributing guide indexed for this repository
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 tracing the Redis adaptor functions used with each and jGet, focusing on how the fetched key and state.references are passed downstream. Review the existing HTTP result shape for comparison; done means agreeing on the metadata shape and making the key reliably available to downstream transformations, with tests covering iteration over Redis keys.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, redis
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100