Use Redis as the main database in your Rails application

Hi I'm new to Redis. I am trying to use Redis as my main database instead of sqlite as provided by default with Rails. I've tried enough googling but couldn't find the stuff I needed. How do you achieve this? Or if I'm wrong, can we use Redis as the main database in a Rails application?

thank

+4


source to share


2 answers


You usually use a library like https://github.com/nateware/redis-objects . As its README says, this isn't just another way to store ActiveRecords, as you can also keep it simple and use MySQL or Postgres if you only want ActiveRecords. Instead, the redis-object will allow you to use the Redis data structures the way they are intended to be used.

This is not an ORM. People who wrap ORMs around Redis are missing the point.

The special thing about Redis is that it allows you to perform rudimentary operations on individual data structures such as counters, lists, and sets. The atomic part is huge. Using an ORM wrapper that fetches the "record", updates the values, then sends those values ​​back, removes the atomicity, stripping away the main benefits of Redis. Just use MySQL, to?



You can also just install the Redis gem and make your own calls to Redis, but this kind of low-level programming will largely abandon the goal of using a powerful framework like Rails.

+2


source


Got it. Redis

cannot be used as a primary database, as it is an in-memory key value store. What if something happens to the memory? The data was not saved.



-1


source







All Articles