Can you save nested objects in redis?
I'm using the node.js driver. One of my key-values is an array of objects. If I dont stringify it results in the string "[object Object]" if i stringify it I get this error:
{
stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'ERR wrong number of argume开发者_JAVA技巧nts for \'hmset\' command'
}
stringifying json is not the right way of using redis. you should generate your own redis hashsets
user:ejder name ejder user:ejder:details:0 age 32 user:ejder:details:1 age 25 (i wish)
that way you can query your data redis-way. Stringifying json is nothing but saving a string and if you use large datasets it will decrease the performance very bad
Stringifying simple object to it's JSON representations should work and it seems that you have some syntax error in your code (can you please update your question with corresponding code where you are doing the HMSET command?). If you are not ok with stringified version, then each of your object in array should have dedicated hash structure where their data would be located.
Alternatively you can try to use node.js implementation of a object-hash mapping library for redis.
精彩评论