In large-scale system development, the cache is undoubtedly crucial, PHP world, although not as Java, there are so many cache solution can choose, but there are still some mature solutions, from "Advanced PHP Programming" I learned some of the following:
1, the language level of optimization: PHP has a lot of engine-level API, through these APIs, can change the behavior of the engine execution, so as to achieve optimal operation. One of the most worthwhile things to do is cache the results of the compilation. As we all know, PHP every execution needs to go through the source code –〉 compiled –〉 intermediate code –〉 engine to do such a process, for some large applications, a considerable amount of time spent on useless compilation (not just the PHP file to access the page needs to be compiled, when the script uses require (), Some of the files included in the include () need to be compiled. By caching the results of the compilation, the performance of the system can be greatly improved (proportional to the complexity and scale of the system).
The three main tools in the PHP world that are capable of compiling the cache are:
The Zend accelerator-a Commercial, Closed-source, For-cost compiler cache produced by Zend Industries
The Ioncube accelerator-a Commercial, Closed-source, but free compiler cache written by Nick Lindridge and distributed by His company, Ioncube
Apc-a free and Open-source compiler caches written by Daniel Cowgill and George Schlossnagle
APC installation method, APC included in the PECL, the specific installation of the following 190-823 190-802:
Run command
#pear Install APC
After that, add the following in the php.ini file:
Extension =/path/to/apc.so
This completes the installation, when the next run PHP,APC will be automatically activated, the results of the compilation into the shared memory cache, the next time you execute it directly from memory to get the results of the execution, do not need to compile again.
Question: Will the PHP,APC be automatically recompiled for changes since the last compilation?
2, PHP code optimization: The use of some tools to compile the city after the production of high-quality intermediate code, specifically as follows:
The Zend Optimizer is a closed-source but freely available Optimizer.
The Ioncube accelerator contains an integrated optimizer.
Proof-of-concept Optimizer in PEAR.
Key features of the optimizer:
1. Clean up useless code, such as dead code that will never execute.
2, the calculation of constants, for example, $seconds_in_day = 24*60*60 directly into $seconds_in_day = 86400;
3, other code optimization functions, such as a statement:
$count + +;
will be optimized for + + $count, making execution faster. Of course, if the statement is $i = $count + +, it will not be optimized
http://www.bkjia.com/PHPjc/508244.html www.bkjia.com true http://www.bkjia.com/PHPjc/508244.html techarticle in large-scale system development, the cache is undoubtedly crucial, in the PHP world, although not as good as Java, there are so rich cache solution can choose, but still some mature ...