PHP Cache Cache Using APC Cache


The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.


sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart

Add Cache:

apc_add ($key, $value , $ttl);
$key = unique cache key
$value = cache value
$ttl = Time To Live;

Delete Cache:


Set Cache Example:

if (apc_exists($key)) {
    echo "Key exists: ";
    echo apc_fetch($key);
} else {
    echo "Key does not exist";
    apc_add ($key, $value , $ttl);


APC is nearly 5 times faster than Memcached.