Several ways to summarize PHP cache technology

Source: Internet
Author: User
Several ways to summarize PHP cache technology

This refers to the data cache is the database query PHP cache mechanism, each time you visit the page, will first detect the corresponding cache data exists, if not exist, connect to the database, get the data, and the query results serialized after saving to the file, the same query results will be directly from the cache table or file obtained.

1. Universal Cache Technology:

Data cache: In this case, the data cache refers to the database query PHP cache mechanism, each time you visit the page, will first detect the corresponding cache data exists, if not exist, connect to the database, get the data, and the query results are serialized and saved to the file, Later, the same query results are obtained directly from the cache table or file. The most widely used example is the search function of discuz, which caches the result ID into a table and searches the cache table the next time the same keyword is searched. For a common method, multiple tables associated with the time, the table of contents generated array to save to a field in the main table, brother Lian Small reminder: when needed to decompose the array, the advantage is only read a table, the disadvantage is that two data synchronization will be many steps, the database is always the bottleneck, with hard disk speed, Is the key point of this.

2. Page cache:

Each time you visit the page, will detect the corresponding cache page file exists, if not exist, connect to the database, get data, display the page and generate the cache page file at the same time, so the next visit to the page file will play a role. (the template engine and some common PHP caching mechanism classes on the web usually have this feature)

3. Time-Triggered cache:

Check that the file exists and that the timestamp is less than the expiration time of the setting, and if the timestamp of the file modification is greater than the current timestamp minus the expiration timestamp, then 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:

Static caching refers to static, directly generated HTML or XML and other text files, there is an update when re-generated once, suitable for the less changing pages, this does not say.

The above content is a code-level solution, the following content is the server-side caching scheme, non-code-level, to have a multi-party cooperation to do

6. Memory Cache:

Memcached is a high-performance, distributed memory object PHP caching mechanism system for reducing database load and increasing access speed in dynamic applications.

7, the buffer of PHP:

There are eaccelerator, APC, Phpa,xcache, this is not to say, search a bunch of a bunch of, see for yourself, know that this thing is OK

8. mysql Cache:

This is also non-code level, the classic database is used in this way, look at the following running time, 0.09xxx and the like

9. Reverse proxy-based Web caching:

such as Nginx,squid,mod_proxy (Apache2 and above are divided into mod_proxy and Mod_cache)

10. DNS Polling:

Bind is an open source DNS server software, this to say it is big, their own search, you know there is this thing on the line.
I know some of the major stations are doing this, said the simple point is a multi-server, the same page or file cache to different servers, according to the North-South automatic resolution to the relevant server.
  • 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.