Does PHP have no CACHE? I really want to do memory cache, non-distributed, is it only possible to do it in the APPLICATION object ?, Net abstract php Cache technology: General cache technology data cache: the data cache here refers to the database query cache. each time you access the page, it will first check whether the cache data exists, if it does not exist, connect to the database, get the data, serialize the query results, and save them to the file. will PHP have no CACHE in the future?
I really want to do the memory cache, non-distributed, is it only possible to do it in the APPLICATION object?
------ Solution --------------------
Net abstract php Cache technology:
General cache technology
Data cache: the data cache here refers to the database query cache. each time you access the page, it first checks whether the cache data exists. if it does not exist, it connects to the database to obtain the data, serialize the query results and save them to the file. later, 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 cache 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 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 cache system that reduces database loads in Dynamic Applications and improves access speeds.
Here is an example of Memcached:
Code
PHP code
connect('localhost', 11211) or die ("Could not connect");$version = $memcache->getVersion();echo "Server's version: ".$version."\n";$tmp_object = new stdClass;$tmp_object->str_attr = 'test';$tmp_object->int_attr = 123;$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");echo "Store data in the cache (data will expire in 10 seconds)\n";$get_result = $memcache->get('key');echo "Data from the cache:\n";var_dump($get_result);?>