Php file cache performance test. Common cache methods for PHP: first, process the data to be cached to form a file that can be directly executed by PHP. When you need to cache data, use the include method to introduce and
Common PHP Cache methods:
First, process the data to be cached to form a file that can be directly executed by PHP. When data needs to be cached, it is introduced and used in the include mode.
Second, serialize the required data through the serialize function and save it directly to the file. When you need to use cached data, read the file content through deserialization, copy the content to the required variable, and then use it.
Test results:
Through tests, we found that the second method, namely serialize, caches data more efficiently. (The data is omitted, and finally the article address is provided for download. you can test it on your own)
Cause analysis:
When reading the cache using the include method, PHP needs to execute several processes.
1. read files
2. parse the included files
3. execute and assign values to variables
When serialize is used to read the cache:
1. read data
2. deserialize data content
3. assign values to variables
Summary and Analysis:
First, the include cache method
Advantage: it increases data confidentiality and security, and the cached content will not be discovered by the outside world.
Disadvantage: the speed is relatively slow.
Purpose: Save data that is not known outside the system, such as web system settings and even MySQL information.
Second, serialize serialization cache method
Advantage: fast.
Disadvantage: Once the file path of the cache system is exposed, the cached content will be leaked.
Purpose: This method can be used to cache the latest articles and related articles without worrying about external data.
Handler: first, process the data to be cached to form a file that can be directly executed by PHP. When you need to cache data, use the include method to introduce and make...