Hello guys i try to get an object global/persistent over more than one php page, so that i do not need to load it everytime.
I read a lot but in the moment i am not really sure, which is now the best way to achieve that, when the object is a bit bigger with e.g. ten multidimensional arrays with each 100 variables or more.
-
The easiest way i think, is to use the session, serialize and unserialize it. But what is about the performance?
-
Store the object in database and send a query to get its values. Maybe faster as Session but in handling not that comfortable?
-
Store the object memcached, but this is only a good solution if i had enough of it. I have a problem with that. What is enough here meaning? In the docs there was not any handy information about it. My managed server has 8 GB Memory…
-
Store the object on the harddrive. Maybe the slowest way?
5.
Another method?
I appreciate any help, link, tutorials, maybe performace checks and so on to better understand this. Maybe one of you can explain which of the methods above should i prefer and why.
Thanx ruven
@Ruven:
the best and the fastest way is to hold the data in the RAM. So in think there are more solutions.
You can use your session like you said and set the session handler to memcache. Then all session data is automaticly stored in memcache.
The second way is to make a “MEMORY” table in your database and store the data in this Table. Then the sessions are stored in RAM but if you restart your server the data from the MEMORY table is lost.
The easiest way is to set memcache as session handler but i am interested in more ideas here.