Redis can fetch outdated data ? #11765
-
If Redis crashes and doesn't have time to write the latest information to disk, will it refetch data from disk when next restart? Problem: If redis is used for caching, the reloaded data no longer matches what it should, and therefore the data is invalid. How to deal with this problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @vincent-herlemont
Yes. If Redis restarts and find persistence files, it will load them. Depending on the server's load, storage, and settings (snapshot frequency/fsync policy), the persisted data may be incomplete (e.g. if the server crashed before writing it). If this is a real concern in your use case, I suggest you don't use persistence and always restart with a cold cache. The alternative would be to setup the server with fast storage, and using AOF on every write, although even this setup isn't guaranteed not to lose writes in extreme cases. |
Beta Was this translation helpful? Give feedback.
Hello @vincent-herlemont
Yes. If Redis restarts and find persistence files, it will load them. Depending on the server's load, storage, and settings (snapshot frequency/fsync policy), the persisted data may be incomplete (e.g. if the server crashed before writing it).
If this is a real concern in your use case, I suggest you don't use persistence and always restart with a cold cache. The alternative would be to setup the server with fast storage, and using AOF on every write, although even this setup isn't guaranteed not to lose writes in extreme cases.