Cache Using APC Cache

suggest change

The old APC extension cached opcodes and user data. On PHP 7 and later, OPcache is the opcode cache, and user data is stored with the separate APCu extension. The calls below are APCu (apcu_*), not the removed apc_* API.

installation

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

Add Cache:

apcu_add($key, $value, $ttl);
// $key is the unique cache key.
// $value is the cached value.
// $ttl is the time to live in seconds.

Delete Cache:

apcu_delete($key);

Set Cache Example:

if (apcu_exists($key)) {
    echo "Key exists: ";
    echo apcu_fetch($key);
} else {
    echo "Key does not exist";
    apcu_add($key, $value, $ttl);
}

Performance:

A 2006 comparison found local APC user-cache reads several times faster than Memcached. That result is old; measure your own workload.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents