N
N
No_Time2012-08-25 00:51:03
Ruby on Rails
No_Time, 2012-08-25 00:51:03

How to create a complex nested Redis model in RoR?

I decided to use redis for something other than session storage and caching. And immediately I ran into a problem that I could not solve by googling (maybe because of Friday Saturday). You need to create a view model:

"news" => 
{
     "user1"=>[
                       {"first_hash"=>"first value"},
                       {"second_hash"=>"second value"},
                       {"third_hash"=>"third value"}, 
                       {"last_key"=>"last value"}
               ],
     "user2"=>[
                       {"first_hash"=>"first value"},
                       {"second_hash"=>"second value"},
                       {"third_hash"=>"third value"}, 
                       {"last_key"=>"last value"}
               ], 
     "user3"=>[
                       {"first_hash"=>"first value"},
                       {"second_hash"=>"second value"},
                       {"third_hash"=>"third value"}, 
                       {"last_key"=>"last value"}
               ]
} 


These are various user actions (aka VKontakte news, facebook, etc.). Actually, because of the heterogeneity of the data, I wanted to use the nosql solution. The structure example is very abstract, in fact, nesting can be more. But I think I'll take a look at the example.

You can use hmset, but then you get the nesting of hashes, but you need to have arrays inside. You can, of course, serialize everything with ruby ​​after hmget, but this does not seem to work, there must be a way to create nesting from hashes and arrays using only the tools built into the radish.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EugeneOZ, 2012-08-25
@EugeneOZ

“Actually, because of the heterogeneity of the data, I wanted to use the nosql solution.”
Here MongoDB will be "just what the doctor ordered".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question