Is memcache data saved even after server restart?
Asked Answered
G

4

5

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?

Garrick answered 20/3, 2012 at 1:51 Comment(3)
See the top answers to #1317352Openmouthed
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.Garrick
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.Garrick
R
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.

Rodie answered 20/3, 2012 at 1:54 Comment(0)
I
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

Intramuscular answered 20/3, 2012 at 1:56 Comment(0)
S
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.

Skinner answered 20/3, 2012 at 2:4 Comment(0)
V
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)

Velda answered 17/2, 2022 at 9:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.