Store the PHP superglobal until restarting the Apache server

Is there a way to store a variable in server RAM using Apache 2 and PHP, holding it until the server shuts down? I need to store a very large array (hashmap) that needs to be initialized once (not once for the user, for example, only when the server starts up) and accessed from different files.

$GLOBALS

does not perform a global trick (I cannot access variables $GLOBALS

from different files, am I doing it wrong?); $_SESSION

does it, but that's not what I want. I need to store it in the instant memory of the server, losing it only when the server restarts.

Obviously, the answer is not "database" as the database query will be slower than accessing the array from RAM.

This can be done easily on a Java server, why not on Apache?

+3


source to share


1 answer


I found a suitable workaround using apc_store ( http://php.net/manual/en/function.apc-store.php ) with time to live = 0. This is not exactly what I need (I think that it still uses serialization), but it's pretty close. Better than memcache.



0


source







All Articles