Skip to content

Nodejs Redis HGETALL return different values from two consecutive calls #2427

Open
@CHYGO1985

Description

@CHYGO1985

Description

Hi there,

I am having a weird issue here.

The scenario is like the following (all these happen in a local environment): I am using the node-redis, and I used HSET to store the following data: {"value":"test3","isAvail":"true","refCount":"0","acctLevel":"0","username":"user3","id":"3"}

Then I read the data from redis, and change refCount from '0' to '1', and save it back to redis via using HSET again, and here is what happens using HGETALL to read from redis 3 times in a row, here is the console.log output:

after1: {"value":"test3","isAvail":"true","refCount":"0","acctLevel":"0","username":"user3","id":"3"} after2: {"value":"test3","isAvail":"true","refCount":"1","acctLevel":"0","username":"user3","id":"3"} after3: {"value":"test3","isAvail":"true","refCount":"1","acctLevel":"0","username":"user3","id":"3"}

I did nothing between the calls. My questions is why the first time it returns refCount as '0' and 2,3 time returns as '1' ?? Is there any cache mechanism in redis? (I tried the same thing via redis-cli: write -> read -> change refCount -> save back), and the first time I call hgetall it returns refCount as '1'

My redis version is : redis_version:6.2.5

Node.js Version

v18.7.0

Redis Server Version

redis_version:6.2.5

Node Redis Version

[email protected]

Platform

macOS

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions