Three cache technologies are commonly used in PHP

Source: Internet
Author: User
This is the Cache settings made on the server, such as Zend's Cache products. The main principle is to save the PHP code files in the memory by one compilation, reduce IO operations to accelerate access, which is not covered in this article

I divided the current php Cache into these four mechanisms. The first method is to load modules, which may be charged, such as ZEND, which may be free of charge; the second method is suitable for mature and large websites, and the third and fourth methods are popular in the PHP industry.

Divided into three categories

1. Cache module

This is the Cache settings made on the server, such as Zend's Cache products. The main principle is to save the PHP code files in the memory by one compilation, reducing I/O operations to speed up access is not covered in this article

2. HTML

You may say that the php html generation method is not included in the scope discussed in this article, but I personally use this method as a Cache method, for example, there are many popular HTML generation programs, such as some CMS in China. this is not included in the scope discussed in this article.

3. generate a Cache file

This is the amount of frequently used and not frequently changed data. it is saved in the text and the mysql Query volume is reduced to speed up program execution. the detailed content will be introduced later.

4. php Cache mechanism

For example, the cache mechanism in the smarty template, such as the current Discuz! The Cache mechanism used in the forum will be described later in detail as Discuz! Forum Software Version 5.0 (maybe you have explained why Discuz! For example, instead of using PhpWind or CMS as an example, it is mainly because Discuz! It works better with the two caching mechanisms that I want to talk about later, while other software products are more or less unsuitable for the requirements in this article.) for example, in the third mechanism, Discuz! Save basic settings and common variables in a file in the forumdata/cache folder.

For example, cache_settings.php stores the data set in the forum in an array and exists in this file. these variables are used by include when these variables are needed; in the fourth mechanism, Discuz! Is to pre-compile the template file in templates/default, that is, to request access to the index. when using the PHP file, the program first checks whether the pre-compiled file has been generated in forumdata/templates. if the file exists, it includes the file. if not, search for the template in the template folder and then generate the file, such a process.

Under this processing mechanism, there will be a lot of waste in the case of small load and small sites, but in the specific implementation of medium and large sites or large and super large sites, the performance is outstanding, however, it seems that all forums are heavily loaded, and there are a bunch of domestic water forums.

Let's take a look at the Phpwind Forum. it is the only PHP forum in China that can be found in Discuz! Obviously, the cache mechanism is not very well handled by a forum system worth mentioning. PW previously appeared to have started as a text Forum, the same text puts a lot of pressure on I/O, especially on load balancing for large and medium-sized sites.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.