Is there a way to cache across invocations in PHP/mod_php?
For example, many different users want 'X' which requires a costly calculation. It only needs to be recalculated periodically though, so if I can cache it at the PHP level, when a user asks for 'X', I can just hand them the value I have cached. (Due to the nature of the application, I can't simply use HTML for cache control).
The best way I've come up with to preserve the cache across invocations is to serialize the variables I want to cache into a file at the end of my PHP code, and read them back when my PHP code starts. For my particular application though, this will waste a lot of time due to all the file IO and parsing.
Is there a better way to do this with PHP/mod_php? Eg, one that can keep the info around in memory? Thanks for any pointers!