Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you save nested objects in redis?

Tags:

node.js

redis

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 arguments for \'hmset\' command' 
}
like image 692
boom Avatar asked Sep 28 '11 01:09

boom


1 Answers

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

like image 89
eyurdakul Avatar answered Oct 01 '22 02:10

eyurdakul