Should I trust Redis for data integrity?

Posted by Jiaji on Stack Overflow See other posts from Stack Overflow or by Jiaji
Published on 2012-06-01T10:01:57Z Indexed on 2012/06/01 10:40 UTC
Read the original article Hit count: 326

Filed under:
|
|

In my current project, I have PostgreSQL as my master DB, and Redis as kind of a slave, e.g., when some user adds another as a friend, first the relationship will be stored in PostgreSQL and then a friend list in Redis will be updated. When some user's friend list is requested, it will be pulled out of Redis instead of PostgreSQL.

The question is: when I update the friend list in Redis, should I get a fresh copy outof PostgreSQL, and replace the old list in Redis with the new one or should I keep the old list and simply SADD the userid into the list? The latter is of course best for performance, but intuitively the former does a better job in keep the data integrity? And if something like Celery is used, is the second method worth the risk?

© Stack Overflow or respective owner

Related posts about Performance

Related posts about redis