How can I set a key-value pair in Redis using the Node.js client?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can I set a key-value pair in Redis using the Node.js client?
Asked by:
65 Viewed 65 Answers

Answer (65)

Best Answer
(241)
You can use the `set` command to set a key-value pair. Here's an example: `client.set('mykey', 'myvalue', (err, reply) => { if (err) console.error(err); else console.log(reply); });`. The `reply` will be 'OK' if the operation was successful.