Difference between #3 and #4 of
Getting the Most out of APC for Yii

Revision #4 has been created by François Gannaz on Mar 7, 2012, 12:37:40 PM with the memo:

small changes (typos and technical details)
« previous (#3) next (#5) »

Changes

Title unchanged

Getting the Most out of APC for Yii

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

caching, apc

Content changed

Preface ------- The [Advanced PHP Cache](http://pecl.php.net/package/APC) is a PHP extension which primarily serves as an opcode cache for PHP. The basic idea is to save PHP from re-evaluating the PHP code to intermediate bytecode on each request. Installing and enabling APC already yields a significant performance benefit. However, APC is not a black box that will magically change all for the better. More over it is important to understand that APC needs memory to operate. Hence, _by enabling APC you are trading memory for speed_.

In addition to the opcode cache, APC can also serve as a user cache for Yii via [CApcCache]. It should be noted that this will make APC's memory needs less predictable.
[...]
Preparing Yii
=============
**The main gain provided by APC is the opcode cache that will speed up each request**. The Yii framework comes with a `yiilite.php` which can be used instead of `yii.php`. Despite its name, it includes the most used classes. The benefit to APC is that the opcode cache can be quickly filled via one single file instead of digging throughincluding several smaller files and dynamically loading several classes. This change must be done in the file `index.php`, in the root directory of your application.

If you wish to use APC as a user cache as well, you'll need to register the CApcCache as cache component in your config. Locate the `components`-stanza in your config and add the following lines:
[...]
Some of the aforementioned settings can be very specific to your setup and your application. So you need to take a look at what APC is doing. There are currently two ways of achieving this:

- APC itself comes witha bundled `apc.php` which will tell you a bit about memory consumption, fragmentation and cache content. You'll most likely find it in `/usr/local/doc/apc`. Copy it to a location where your webserver can reach it and take appropriate measures to protect it from unauthorized access
 (open the php file and set the password in its first lines). - Available as an extension to your very own app comes the [apcinfo extension](http://yiiframework.com/extension/apcinfo) which does roughly the same job as `apc.php` but integrates nicely into your app.
15 0
19 followers
Viewed: 51 603 times
Version: 1.1
Category: How-tos
Tags: apc, caching
Written by: Da:Sourcerer
Last updated by: Da:Sourcerer
Created on: Mar 5, 2012
Last updated: 10 years ago
Update Article

Revisions

View all history