views:

32

answers:

1

In PHP, when I use the file handler for session storing,does Apache caches the SESSION in memory?
If not, would a usage of db storage engine on memory tables (mysql) would be a good idea?

+1  A: 

Apache by itself doesn't "cache" the session file to memory : Apache has nothing to do with the session : it's purely something related to PHP, and unrelated to Apache.

PHP itself doesn't "cache" the session file to memory either : it writes it to disk (And, for security, the operating system probably really writes that file to disk)


Using a database could help, maybe, about disk-access ; but it would mean a network connection to another server, it would make MySQL work... Not necessarily that great.

Instead, I would rather use memcached to store my session ; it's a network daemon (which works in clusters, which means you can have several machines with memcached servers -- useful if you don't have enough memory on one server) that stores data in memory.

And memcached is quite frequently used to store session data -- I'm currently using memcached for that (amongst other things) on a project.

See the memcache section of the PHP manual : you'll need to install a PHP extension, if you want to communicate with memcached.

Pascal MARTIN
+1 for memcached. This is what we use on our cluster.
jasonbar