4

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?

alecwhardy
  • 2,698
  • 6
  • 27
  • 33
  • See the top answers to http://stackoverflow.com/questions/1316852/alternative-to-memcached-that-can-persist-to-disk – jli Mar 20 '12 at 01:58
  • I was originally going to have a database handler for sessions, but I heard memcached is much quicker and less resource intensive. However, if simply rebooting the server will clear all memcached data, I was thinking on using a dual database/memcached handler. However, after thinking more about this this would not be reasonable: the data changes every page reload. Caching simply can not work for session data. – alecwhardy Mar 20 '12 at 05:15
  • database is the only way to store session data if you want a 100% surefire mean of never clearing the session information. memcache only if the session information can easily be recreated on request. – alecwhardy Mar 20 '12 at 05:16

4 Answers4

5

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.

D Mac
  • 3,727
  • 1
  • 25
  • 32
4

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

welsonla
  • 328
  • 3
  • 15
4

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.

0

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)