Tuesday, March 2, 2010

PHP APC

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.

Check for the installation using:php -r 'phpinfo();' |grep apc 
If its not installed already use(on ubuntu):
  
 sudo apt-get install php-apc
 sudo /etc/init.d/apache2 restart

 or
 apt-get install apache2-prefork-dev
 pecl install apc

 
Use dpkg -L php-apc to know where the files are installed

There are two primary decisions to be made configuring APC. First, how much memory is going to be allocated to APC; and second, whether APC will check if a file has been modified on every request. The two ini directives that control these settings are apc.shm_size and apc.stat, respectively. Read the sections on these two directive carefully below. 



APC Functions

Table of Contents

Eg:

1)$bar 'BAR';apc_store('foo'$bar);var_dump(apc_fetch('foo'));?>
 

outputs : BAR 


2)
$constants = array(
    
'ONE'   => 1,
    
'TWO'   => 2,
    
'THREE' => 3,
);
apc_define_constants('numbers'$constants);
echo 
ONETWOTHREE;?>
 
From :php.net/apc
 
 

No comments:

Post a Comment