In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "what are the types of php cache". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
There are five types of php cache: 1, data cache, that is, database query PHP cache mechanism; 2, page cache; 3, time-triggered cache; 4, content-triggered cache, that is, when data is inserted or updated, the PHP cache mechanism is forced to update; 5, static cache.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The standard flow of a website or an application is that the browser sends a request to the application server, and the application server makes some calculation and logical judgment before requesting the database. After receiving the request, the database returns the data to the application server after calculation. The application server calculates again and returns the data to the browser.
Then, with the increase of the complexity and concurrency of web business, the application server does more and more computing and logical processing, but the resources of the application server are limited, and the number of requests received and processed by the database per second is also limited. In order to provide as much throughput as possible in limited resources, it is necessary to reduce the amount of computation and shorten the request process (reducing the network Imax O or the hard disk IBO). At this point, cache (Cache) is used.
Php cache type
1. Data cache:
Data cache: the data cache here refers to the database query PHP cache mechanism. Every time you visit a page, you will first detect whether the corresponding cached data exists. If it does not exist, connect to the database, get the data, and serialize the query results and save them to a file. Later, the same query results will be obtained directly from the cache table or file.
The most widely used example is Discuz's search function, which caches the results ID into a table and searches the cache table the next time you search for the same keyword.
To take a common method, when multiple tables are associated, save the generated array of the contents in the schedule to a field of the main table, and decompose the array when needed. This advantage is to read only one table. The disadvantage is that the two data synchronization will be many more steps, the database is always the bottleneck, using the hard disk for speed is the key point.
2. Page cache:
Every time you visit a page, you will first check whether the corresponding cache page file exists. If it does not exist, connect to the database, get the data, display the page, and generate the cache page file at the same time, so that the page file will work the next time you visit it. (this feature is usually available in template engines and some PHP caching mechanism classes common on the Internet)
3. Time-triggered cache:
Check whether the file exists and the timestamp is less than the set expiration time. If the timestamp modified by the file is larger than the current timestamp minus the expiration timestamp, then the cache is used, otherwise the cache is updated.
4. Content trigger cache:
Forces the PHP cache mechanism to be updated when data is inserted or updated.
5. Static cache:
The static cache here refers to static, directly generate text files such as HTML or XML, and re-generate when there is an update, which is suitable for pages that do not change much, not to mention.
This is the end of the content of "what are the php cache types". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.