Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis concept: In memory or DB?

Tags:

redis

Based on the http://redis.io/topics/faq

Redis is an in-memory but persistent on disk database.

So may I know redis save key/value in memory or in disk? or both?

When writing value in Redis, it write into memory and disk at the same time?

Thanks for the concept.

like image 976
TheOneTeam Avatar asked Feb 03 '26 05:02

TheOneTeam


2 Answers

depending on how you configure it, redis can periodically back up the existing state to disk, but otherwise, everything is in memory.

like image 128
Haleemur Ali Avatar answered Feb 08 '26 05:02

Haleemur Ali


Redis will atomically snapshot its memory state to disk if so configured. See this part of the docs for more info:

http://redis.io/topics/persistence

So you can have different levels of durability. For the most part, when you get a key, it is out of memory and when you set a key it is also in memory. The data is written to disk independently of read/write operations.

like image 28
Daniel Williams Avatar answered Feb 08 '26 03:02

Daniel Williams