No, by default, Memcached is not persistent. It means that the data in Memcached does not persist after a restart or shutdown of the Memcached server. When the server restarts, it starts with an empty cache.
However, 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:
memcached -m 64 -p 11211 -u memcached -l 127.0.0.1 -s /path/to/memcached/data/file
It's important to note that enabling persistence can affect performance since writing data to disk is slower than writing to memory. Additionally, Memcached does not provide any guarantees about the durability of the data. Data loss can occur if the server crashes or loses power before it can write data to disk. Therefore, it's recommended to use Memcached with persistence only for caching non-critical data.