Home > Common Problem > Describe commonly used buffering techniques

Describe commonly used buffering techniques

hzc
Release: 2020-06-12 15:24:18
Original
5221 people have browsed it

Describe commonly used buffering techniques

1. Data cache

The data cache mentioned here refers to the database query cache. Every time a page is accessed, it will be detected first. Whether the corresponding cached data

exists, if not, connect to the database, obtain the data, and serialize the query results and save them to the file.

The same query results will be processed directly in the future. Obtained from cache table or file.

The most widely used example is the search function of Discuz, which caches the result ID into a table. The next time you search for the same keyword,

search the cache table first.

As a common method, when multiple tables are associated, generate an array and save the contents in the attached table to a field in the main table.

Decompose the array when needed, like this The advantage is that only one table can be read, but the disadvantage is that synchronization of the two data will require many more steps.

The database is always the bottleneck, and using the hard disk for speed is the key point of this.

2. Page caching

Every time you access a page, it will first detect whether the corresponding cached page file exists. If it does not exist, connect the data

Library, get the data, display the page and generate a cache page file at the same time, so that the page file will be used

the next time you visit. (Template engines and some common cache classes on the Internet usually have this function).

3. Time-triggered cache

Check whether the file exists and the timestamp is less than the set expiration time. If the timestamp of the file modification is less than the current timestamp

If the expiration timestamp is large, then use the cache, otherwise update the cache.

4. Content-triggered caching

When data is inserted or updated, the cache is forced to be updated.

5. Static cache

The static cache mentioned here refers to static, directly generate text files such as HTML or XML, and regenerate when there are updates

Once, suitable for pages that don’t change much.

The above content is a code-level solution. I directly CP other frameworks and am too lazy to change. The content is similar and it is easy to

It can be done, and it can be used in several ways, but the following content is a server-side caching solution, which is not code-level. It requires the cooperation of multiple

parties to achieve it.

6. Memory cache

Memcached is a high-performance, distributed memory object caching system used to reduce database load in dynamic applications,

Improve access speed.

7. PHP buffers and accelerators

There are eaccelerator, apc, phpa, xcache.

8. MYSQL cache.

9. Web cache based on reverse proxy

Such as Nginx, SQUID, mod_proxy (apache2 and above are divided into mod_proxy and mod_cache).

The above is the detailed content of Describe commonly used buffering techniques. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template