Dragonfly Cloud announces new enterprise security features - learn more

Dragonfly

Question: Is Redis cache persistent?

Answer

Yes, Redis can support persistence, although it's primarily known as an in-memory data store. There are two main mechanisms for achieving this:

  1. RDB (Redis Database file): This is a point-in-time snapshot of your dataset at specified intervals. It's ideal when backups are crucial, but it can lead to data loss if a crash occurs between snapshots.
# To enable RDB persistence in Redis configuration
save 900 1 # save the DB if at least 1 key changes in 900 seconds
dbfilename dump.rdb
dir /path/to/your/data
  1. AOF (Append Only File): Here, every write operation is logged in the AOF. This persists more data than RDB but with a performance cost. If durability is more important than performance, AOF should be used.
# To enable AOF persistence in Redis configuration
appendonly yes
appendfilename "appendonly.aof"

Redis also allows you to use both RDB and AOF. If configured this way, Redis will use the AOF file to load the dataset at startup, and will continue to persist data using both RDB and AOF.

Keep in mind that configuring Redis for persistence has implications for memory usage and performance. Therefore, choose based on what fits your application needs best.

Was this content helpful?

Other Common In Memory Questions (and Answers)

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost