Home > Article > Backend Development > Types of cache in php
PHP cache includes PHP compilation cache and PHP data cache. PHP is an interpreted language that compiles and runs at the same time. The advantage of this operating mode is that program modification is very convenient, but the operating efficiency is very low. The PHP compilation cache has been improved to deal with this situation, so that the PHP language can cache the compilation results of the program as long as it is run once. In this way, every subsequent run does not need to be compiled again, which greatly improves the running speed of PHP. PHP data caching is used to cache data processing in the actual development of PHP. The two main directions are: caching database data and caching PHP template data.
Recommended tutorial: PHP video tutorial
##PHP compilation cache
Currently the most common PHP compilation caching tools are: APC, Accelerator, xcache (domestic), etc. PHP is an interpreted language. When executing code in PHP language, the following two steps are required: 1. Compilation process. PHP reads the file, compiles the file, and generates intermediate code that can be executed on the Zend Engine virtual machine. 2. Execution process. PHP executes the intermediate code directly. The following two situations will lead to low efficiency of PHP running program code: 1. Even if the PHP code file has not changed, it will be recompiled by PHP. 2. If there are referenced files, PHP will also spend time recompiling these referenced files. Therefore, the PHP compilation caching tool is required to cache the compilation results of the PHP program. In this way, the PHP program only needs to be compiled once, and there is no need to do meaningless compilation again.PHP data caching
PHP data caching includes caching database data and caching PHP template data. Tools for caching database data include memcache, etc. Tools for caching PHP template data mainly include smarty and so on.The above is the detailed content of Types of cache in php. For more information, please follow other related articles on the PHP Chinese website!