Home > Backend Development > PHP Tutorial > Using F method in ThinkPHP to implement fast caching example_PHP tutorial

Using F method in ThinkPHP to implement fast caching example_PHP tutorial

WBOY
Release: 2016-07-13 10:28:13
Original
780 people have browsed it

Generally, caching in file mode can meet the requirements, and thinkPHP also provides a fast caching method F method specifically for file mode.
Since uses the PHP return method, its efficiency is higher than the S method .

The F method has the following characteristics:

1. Simple data caching;
2. Save in file form;
3. Use PHP to return data to load the cache;
4. Support subdirectory caching and automatic creation;
5. Support Delete cache and batch delete;

Copy code The code is as follows:
$path="../Public/Runtime/";
$str="fastrunaaaaaaaaaaaaaaaa ";
F("str/ffun",$str,$path);

In this way, the content of the $str string is placed in the file ../Public/Runtime/str/ffun.php

The file content of

ffun.php is as follows:

Copy code The code is as follows:
return 'fastrunaaaaaaaaaaaaaaaa';
?>

Deleting cache is also easy:

Copy code The code is as follows:
F("str/ffun",NULL);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/802213.htmlTechArticleGenerally, file-based caching can meet the requirements, and thinkPHP also provides a fast file-based cache. Cache method F method. Since the PHP return method is used,...
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