If I store contents of a text file in a session variable in php, will it stay in memory for the period of that session?
I have a small project where I need to perform searches in that specific text file which is just over 1mb. I'm thinking of using a session variable if it stays in memory, so that I don't have to read this file again and again.
No, sessions will be stored default in files (e.g. in /tmp). Of course, you can use the memory with for example memcached. It's also possible to use a database for sessions.
But, if you have enough memory, store your sessions in memory (very fast). Memcached is a great distributed memory object caching system. See http://memcached.org for more information.
And here about the memcached extension for php: http://php.net/manual/en/book.memcached.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With