Hari Smith
Hari Smith

Reputation: 143

How to updata redis cache using node js

I tried redis cache in node js code.its working fine but its throwing warring msg.how to update redis cache in node js.

Warning msg
node_redis: Deprecated: The GET command contains a "undefined" argument. This is converted to a "undefined" string now and will return an error from v.3.0 on. Please handle this in your code to make sure everything works as you intended it to.

package.json

"dependencies": {
    "express": "^4.17.0",
    "fs": "0.0.1-security",
    "joi": "^14.3.1",
    "mongodb": "^3.2.5",
    "mongodb-autoincrement": "^1.0.1",
    "nodemon": "^1.19.1",
    "querystring": "^0.2.0",
    "redis": "^2.8.0",
    "url": "^0.11.0",
    "util": "^0.12.0"
}

Upvotes: 1

Views: 1293

Answers (1)

Paresh Barad
Paresh Barad

Reputation: 1609

I think Its help you, You can update Redis cache by following method.

const redis = require('redis');
// create and connect redis client to local instance.
const client = redis.createClient(6379);

//key to store results in Redis store
const redisKey = 'user:data';

client.setex(redisKey, 3600, JSON.stringify({name: "Jelly Fish"}));

Upvotes: 1

Related Questions