mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-17 11:10:37 +02:00
Merge pull request #233 from staabm/patch-1
Update _posts/10-03-01-Object-Caching.md
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user