Simple Tutorial of APC Cache With PHP

This tutorial will explain how to save object or array into cache using PHP APC Cache, here i will show you, how you can use APC Cache in PHP.

When we are working on huge amounts of database and we need to get huge amount of data from tables.There is one option is to get each time records from database otherwise we store data into cache, We can hit database only once and save records into cache object and use this object again and again.

Also checkout other tutorial of PHP Cache,

Below tutorial are using PHP APC cache to save object into cache,main benefit of cache objects are remove extra loads from database and improve application performance.

Here, We are saving config associative array in cache object, Whenever we need config data. First, we will look data into cache if exits then we will use it otherwise create new cache object and saved config data in cache object.

Key Terms of PHP APC cache:

apc_fetch($onjetName) : This method is used to fetch object from cache.
apc_add('config', $data, 120) : Add cache object in APC cache.

Where params are:

config: target object name
$data: Source array name
120: Time duration when this object expired.

Result:

apc_cache