'Is memcache data saved even after server restart?

If a session handler is based off of memcached, and the memcache server is restarted, is the data saved or does all session information need to be recreated?

If not, is memcached even a reliable for session storage? Or is it possible to create a session handler that uses both MySQL and memcache? How?



Solution 1:[1]

When you restart memcached, you lose all the content and it will need to be resourced (from the origin, wherever that is) when it is next requested.

Solution 2:[2]

the data save in the memory,when you restart your server,you'll lost all the data you stored in the memcache

If you just restart your web server,the data still in the memory

Solution 3:[3]

memcached is a memory caching system that store data and objects in RAM, so if you restart the server you will lost the information. Try to use Redis ( http://redis.io/ ) for your needs.

Solution 4:[4]

Over time, in the 1.5.18 update in 2019, They added an option to specify a memory file and save it on restart that responding to the SIGUSR1 signal.

If you want to use it, add -e <path/file> or --memory_file=<path/file> as an option value when running the memcached service. (This area needs to be accessed by memcached, so you need to check permissions. In most linux environments, the /tmp/ path worked well.)

(Note: https://github.com/memcached/memcached/wiki/ReleaseNotes1518)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 D Mac
Solution 2 welsonla
Solution 3 César Rodríguez
Solution 4 Moure Dievarse