Skip to main content

Where does Redis store data by default?

By default, Redis stores data in RAM, and for long-term persistence it uses files on disk, but only as a backup copy of what's in memory.

1. The primary store is RAM

Every key, value, and data structure lives in the Redis process's memory. That's exactly why Redis runs so fast: accessing RAM is instant, with no disk access needed.

2. Backup persistence

Redis can save the contents of memory to disk in two ways:

(a) RDB (Redis Database File)

  • creates snapshots of the data at set intervals;
  • the default file:
javascript
dump.rdb
  • the default path:
javascript
/var/lib/redis/

or (on Windows):

javascript
C:\Program Files\Redis\

(b) AOF (Append Only File)

  • logs every data-changing operation;
  • the default file:
javascript
appendonly.aof

3. Settings in the config file (redis.conf):

javascript
dir /var/lib/redis/ # the directory where files are stored dbfilename dump.rdb # the snapshot file's name appendonly yes # enable the AOF log (optional)

Summary:

  • Redis keeps its active data in RAM.
  • By default, it periodically snapshots memory into a file, dump.rdb, inside /var/lib/redis/.
  • On restart, Redis restores data from that file back into memory.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.