Home >Backend Development >PHP Tutorial >PHP cache related functions
The so-called cache refers to some public information stored on the server side. The cache lives and dies with the server. When we save the cache, we can specify the time for the next update. For example, if we want to update every 5 minutes, we can record the time of the last update. Compared with the current time, if it is greater than 5 minutes, read it. Database, update the cache, otherwise read the cache data directly. Of course, the cache needs to be activated by the client user, only once.
Caching can speed up display.
void ob_start()
Function: Open the input buffer
Description: When the buffer is activated, all non-file header information from PHP will not be sent, but will be saved in the internal buffer. In order to output the contents of the buffer, you can use ob_end_flush() or flush() to output the contents of the buffer.
void flush(void)
Function: Refresh the output cache
Description: Refresh the buffer of the PHP program, regardless of the circumstances under which PHP is executed (CGI, web server, etc.). This function sends all the program's output so far to the user's browser.
string ob_get_contents(void)
Function: Return the contents of the output buffer
Description: Just get the contents of the output buffer, but do not clear it. If the output buffer is invalid, it will return FALSE
.
intob_get_length ( void )
Function: Return the length of the output buffer content
Description: Return the length of the output buffer content; or return FALSE
- if there is no functioning buffer.
boolob_end_clean ( void )
Function: Clear (erase) the buffer and close the output buffer
Description: This function discards the contents of the top-level output buffer and closes this buffer. If you want to further process the contents of the buffer, you must call ob_get_contents before ob_end_clean(), because the buffer contents will be discarded when ob_end_clean() is called.
voidob_implicit_flush ([ int$flag
= true ] )
Function: Turn on/off absolute flush
Description: The default is to turn off the buffer, When absolute output is turned on, each script output is sent directly to the browser, eliminating the need to call flush().
The above introduces the PHP cache related functions, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.