PHP Cache mechanism. Through the general cache technology data cache on this site: the data cache here refers to the PHP Cache mechanism for database queries. every time you access the page, the corresponding cache data will be checked first through
General cache technology
Data cache: the data cache here refers to the PHP Cache mechanism for database queries. each time you access the page, it first checks whether the cache data exists. if it does not exist, it connects to the database, obtain the data and serialize the query results and save them to the file. the same query results will be obtained directly from the cache table or file.
The most widely used example is the Discuz search function. The result ID is cached in a table and the table is searched in the cache next time when the same keywords are searched.
For example, when multiple tables are joined, an array generated in the appendix is saved to a field in the master table. if necessary, the array is decomposed, the advantage is read-only tables. The disadvantage is that two data synchronization steps are many more steps, and the database is always the bottleneck. Changing the disk speed is the key point.
Page cache:
Each time you access the page, the system first checks whether the corresponding cached page file exists. if it does not exist, it connects to the database to obtain data, displays the page, and generates cache page files at the same time, in this way, the page file will play a role in the next visit. (The template engine and some common PHP Cache mechanism classes on the Internet usually have this function)
Time-triggered cache:
Check whether the file exists and the timestamp is earlier than the set expiration time. if the modified timestamp of the file is greater than the current timestamp minus the expiration timestamp, use the cache; otherwise, update the cache.
Content trigger cache:
When data is inserted or updated, the PHP Cache is forcibly updated.
Static cache:
The static cache mentioned here refers to static, which directly generates HTML, XML, and other text files. it is re-generated once when there is an update. this is suitable for pages that do not change much.
The above content is a code-level solution. I am not too lazy to change the content of the CP framework. the content is similar and easy to implement. it can be used together in several ways, however, the following content is a server-side cache solution. non-code-level solutions can only be achieved through multi-party cooperation.
Memory cache:
Memcached is a high-performance, distributed memory object PHP Cache mechanism system that reduces database loads in Dynamic Applications and improves access speed.
Php buffer:
There are eaccelerator, apc, phpa, and xcache. you don't need to talk about this. you can search for a bunch of them and read them by yourself. if you know what it is, OK.
MYSQL cache:
This is not code-level. the classic database uses this method. See the following running time, such as 0.09xxx.
My post part is modified according to the guy in blue. ini. the MYISAM table of 2 GB can be around 5s. it is said that he has changed it for almost a year.
Reverse proxy-based Web cache:
For example, Nginx, SQUID, mod_proxy (apache2 and above are also divided into mod_proxy and mod_cache)
NGINX example
DNS round robin:
BIND is an open-source DNS server software, which is too big to be mentioned. you can search for it by yourself.
I know that chinacache and other major sites are doing this. Simply put, they are multiple servers and cache the same page or file on different servers, it is automatically resolved to the relevant server by north and south.
Middleware universal cache technology data cache: the data cache here refers to the PHP Cache mechanism for database queries. each time a page is accessed, the corresponding cache data will be checked first...