1

I am using Redis solely as a cache server, so both RDB & AOF are turned off as I already have a DB in place and having 2 layers that do the same thing is an overkill.

While this setup works perfectly when the DB is the only source of truth, my question is more about what happens when you use Redis to keep tracking of things like game scores, pages views, analytics from a webhook, etc..

As of now, we don't have any persistence for Redis, it means that if the server crash/restart all those data are gone.

so what would be the best way to keep the DB in-sync with the Redis data?

  • maybe set up a cron job that gets the data from Redis every 1 min and updates the DB.

  • maybe instead of interrupting Redis every min because of its single-threaded nature & to avoid any data miss, we can add the data to a queue that runs when the size = 50 or something, which then updates the DB

I'm using laravel so any examples following its ecosystem are appreciated, but also any thoughts are very welcomed.

ctf0
  • 6,991
  • 5
  • 37
  • 46
  • how about setting up a replica (master/slave in redis terminology), and configure the replica to persist? but: if it is *just* cache... it is inconvenient but not necessarily an actual problem if the data is lost – Marc Gravell May 09 '18 at 22:40
  • i understand, thats why i explained the other usage i offload to redis, like in/decrement of values, which is much faster than updating the db on each change – ctf0 May 09 '18 at 23:19

0 Answers0