APC Cache Example: Simple Tutorial of APC Cache With PHP

This tutorial is explained how to save object or array into cache using apc Cache, here i will show you how you can use APC in PHP.
When we are working on huge amounts of database and we need to get huge amount of data from tables.One option is to get each time records from database or other is we 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 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 in cache if exits then we will use it otherwise create new cache object and saved config data in cache object.

Key Terms of 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.


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