Merge pull request #233 from staabm/patch-1

Update _posts/10-03-01-Object-Caching.md
This commit is contained in:
Phil Sturgeon
2013-01-06 17:09:36 -08:00

View File

@@ -32,12 +32,13 @@ Example logic using APC:
{% highlight php %}
<?php
// check if there is data saved as 'expensive_data' in cache
if (apc_fetch('expensive_data') === false) {
// data is not in cache; save expensive call for later use
apc_add('expensive_data', get_expensive_data());
$data = apc_fetch('expensive_data');
if ($data === false) {
// data is not in cache; save result of expensive call for later use
apc_add('expensive_data', $data = get_expensive_data());
}
print_r(apc_fetch('expensive_data'));
print_r($data);
{% endhighlight %}
Learn more about popular object caching systems: