Now a days most of the website are used to cache their data to reduce the server load, Also speed up the response. We are going to discuss about the APC – Alternative PHP Cache.
APC is a Alternative PHP Cache as I already mentioned, its used to cache the data, remove and expire in the given time. To work with APC first we need to enable php_apc.dll in windows and php_apc.so in Linux operating system.
Where to use APC ?
Consider you have a website with lots of content driven from database with data for all the users, on that time you cannot query the database each and every time. To avoid this case we will cache the data and share between the users. This will allow one time query and share the same data between the users.
Let’s see about fews function in APC.
apc_add – function used to store a data in key format and expire it in given TTL.
apc_add ( array $values [, mixed $unused = NULL [, int $ttl = 0 ]] )
Assigning value into $myData variable
<?php $myData = 'Welcome to APC'; apc_add('myData',$myData);
apc_fetch – function used to fetch data from the given key. Continue reading “Caching the Data using APC – Alternative PHP Cache”