accessing cache inside a promise is not working ok
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.6k
- Forks
- 2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 40
Description
Issue
I am doing the following inside a function which is called as a promise:
let cachedData = await init(redisKey);
if(cachedData){
logger.info("FOUND CACHED MENUDATA...");
return cachedData;
} else {
logger.info("NOTFOUND CACHED MENUDATA...", venueId);
}
However the control always comes to the else and prints "NOT FOUND CACHED MENUDATA". After that it prints logs inside the redis.readCache function.
const init = async(redisKey) => {
const cachedData = await redis.readCache(redisKey);
console.log(Hi CACHED DATA GOT,cachedData);
return cachedData;
};
Environment
- Node.js Version:
8
- Redis Version:
3
- Platform:
ubuntu 20
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
No source file or test is named. Start by reproducing the reported call through init(redisKey), then inspect redis.readCache and the promise timing around its return. Done means a cache hit is returned from init before the fallback branch runs, with a regression test covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, redis
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100