No, by default, Memcached doesn't write data to disk. It stores all its data in memory, which makes it extremely fast for read and write operations. However, this also means that if the server crashes or is restarted, all data stored in Memcached will be lost.
Memcached provides an option to persist data to disk using the
-s option when starting the server. This option allows you to specify a file path where Memcached will store data in case of a server restart or crash. By doing so, you can ensure that cached data is not lost, even if the server goes down.
Here's an example of how to start Memcached with persistent storage:
-s option specifies the path to the file where Memcached should store its data. You can use any file path as long as the user under which Memcached is running has write access to the directory.
It's worth noting that using persistent storage might impact the performance of Memcached since it adds disk I/O operations to read and write operations, making them slower. Therefore, it's recommended to carefully consider your use case before enabling persistent storage.