I'm a Java and C# developer, and, I admit, I'm not that good in PHP.
I need to store an object in an application scope that lives as long as the app itself is running. I can't save it in the Session, because it expires, also I can't serialize it to disk.
Is there something like a C# Application
object in PHP?
2018 Edit: Time has not been kind to APC, especially since PHP 7 includes bundled support for Zend Optimizer+, which does largely the same thing (except the key-store). These days, the key store aspect has been forked over into the APCu project.
However, in 2018, the preferred key-store of choice is Redis. See the ext-redis project for details.
PHP has an application scope of sorts. it's called APC (Alternative PHP Cache).
Data should be cached in APC if it meets the following criteria:
APC is installed on a great many hosts already, but follow the aforementioned guide to get installed on your box. Then you do something like this:
if (apc_exists('app:app_level_data') !== false)
{
$data = apc_fetch('app:app_level_data');
}
else
{
$data = getFromDB('foo');
apc_store('app:app_level_data', $data);
}
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