user479053
user479053

Reputation:

Redis and django

Redis seems to be a popular choice for caching in django, but is it also a viable option for using as a database for my django models as well. I'm considering moving a large category system from MySQL to Redis, lots of very small records (just name, parent_id, and id) so, though i'm fairly new to the idea of a key-value database, this seems to make a lot of sense?

The more I search around it doesn't look like there is an option to simply hookup a redis backend to django for syncing with Models?

Upvotes: 2

Views: 3068

Answers (2)

Muhammad Faizan Fareed
Muhammad Faizan Fareed

Reputation: 3758

I'm late but it can help others.

Redis can be both

  1. As a Primary database
  2. Cache

Django officially support MYSQL and Postgres databases because it uses ORM (Object Relational Mapper).

So you can use MYSQL or Postgres as a Primary database and Redis for caching your most used models using Hashing in Redis.

Redis is basically in-memory key-value store if any failure occurred your data will be lost.

But Redis also support persistence you can check this.

Redis persistence official doc


Recommendations

I recommend use both MySQL/Postgres as primary database for Django to take advantages of ORM and Redis/memcached for caching.

Upvotes: 1

Piotr Duda
Piotr Duda

Reputation: 1815

The official Django framework works only with RDBMS. In your case I would look into projects like Django-nonrel. They blogged about Redis backend.

Upvotes: 3

Related Questions