Reputation: 417
Is it possible to store multidimensional array in Redis hash
For example
HMSET('Marray','Name'=>"test12",
"Age"=>"45",
"Salary"=>"50000",
"GENDER"=>array("M"=>"1","F"=>"2"))
Or is any other possibility to store the above values
Upvotes: 3
Views: 7176
Reputation: 1
This page talks about this. Redis may not be the best suit for multidimensional data though. https://redis.io/topics/indexes
Upvotes: 0
Reputation: 17500
I'd suggest storing the array in its own key (as a hash, sorted set, or list) and storing its key in your hash/records. You'll presumably want to assign a prefix to all of those keys (so you can manage the keyspace.
Upvotes: 1
Reputation: 230336
You can serialize that sub-array (as JSON, for example) and store it in a hash field. Redis doesn't support arbitrarily nested structures.
Or you can even serialize the whole structure and store it as plain string.
Upvotes: 10