redis / redis/node-redis

data loss when multiple call in one client

Open
#1,560 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

I loging when function fetch data into MongoDB (estimate data plain Json object is ~7MB)
I must prefer data to client (fetch products multiple condition stack card) and must call API 4-5 request at moment time

one call at one time cache will fine but stack call 4-5 request at one sometime some request will errors

Here is Error Cache when call .get
took time 0.8977ms (String is 44711 charectors)
Here is Complete Correct data
took time 101.0482ms (String 7357205 charectors))

Here Code
let GetProdCache = await ctx.redisGet(mongoDB_Prod_${storeuid})
if (GetProdCache) {
return JSON.parse(GetProdCache)
}
else {
let fetch = await products.findOne({ storeuid }).lean()
ctx.redis.setex(mongoDB_Prod_${storeuid}, 100, JSON.stringify(fetch))
return fetch
}

Environment
  • Node.js Version: 12.18.4
  • Redis Version: Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=636cde3b5c7a3923
  • Platform: windows 10 build 19041.746

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Redis get/set calls shown in the issue and reproduce the behavior using several concurrent requests against the large JSON value. Done means concurrent cache reads return complete, parseable data without losing or truncating the stored value.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, node.js, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.