1

I want to use Hash of Redis and store a JSON Object in one key and Array in other. How i can achieve this.

For example when i run this:

redis.hmset(`channel`, 'key1', 'someValue', 'key2', [{x: 1}])

then it gives the error.

But if i change the value of key2 to string it store it in form of string. I wnat to store the JSON data. How can i do so?

I am using Node and redis npm package.

Guy Korland
  • 9,139
  • 14
  • 59
  • 106
Digvijay Rathore
  • 637
  • 1
  • 6
  • 21

1 Answers1

0

There is no native way to store an array in Redis Hash.

But, you can use the Redis Module RedisJSON which adds native JSON support to Redis. It has couple of node.js clients you can use.

e.g. redis-modules-sdk and redis-rejson

Guy Korland
  • 9,139
  • 14
  • 59
  • 106