jkd
06-23-2006, 02:49 AM
So I have an imaginary share.php. Say 10 users are submitting data to that script - every time they submit their own data, they get the most recent submissions of others as their response.
Now, this will happen very often, every couple of seconds at least. File IO is slow, so writing to a temporary file is terrible. Similarly, hitting a DB everytime feels very inefficient (though I suppose if the DB is smart, it'll keep the row in memory so I just suffer a few API calls but no real File IO or processing costs).
I'm under the impression the mod_php keeps the same interpretter running for all script calls, so it seems reasonable that I should be able to modify the actual interpretter's state with data (or do the functional equivalent - perhaps some deliberately exposed "Global" object). I know that Java servlets are perfect for this, but I'm unfortunately limited to a PHP environment.
Ultimately, is there any way in PHP to save data directly to the interpretter's state, so subsequent script executions can pull the data directly from memory and alter it themselves instead of relying on some indirect data storage mechanism?
Now, this will happen very often, every couple of seconds at least. File IO is slow, so writing to a temporary file is terrible. Similarly, hitting a DB everytime feels very inefficient (though I suppose if the DB is smart, it'll keep the row in memory so I just suffer a few API calls but no real File IO or processing costs).
I'm under the impression the mod_php keeps the same interpretter running for all script calls, so it seems reasonable that I should be able to modify the actual interpretter's state with data (or do the functional equivalent - perhaps some deliberately exposed "Global" object). I know that Java servlets are perfect for this, but I'm unfortunately limited to a PHP environment.
Ultimately, is there any way in PHP to save data directly to the interpretter's state, so subsequent script executions can pull the data directly from memory and alter it themselves instead of relying on some indirect data storage mechanism?