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 %} {% highlight php %}
<?php <?php
// check if there is data saved as 'expensive_data' in cache // check if there is data saved as 'expensive_data' in cache
if (apc_fetch('expensive_data') === false) { $data = apc_fetch('expensive_data');
// data is not in cache; save expensive call for later use if ($data === false) {
apc_add('expensive_data', get_expensive_data()); // 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 %} {% endhighlight %}
Learn more about popular object caching systems: Learn more about popular object caching systems: