Implement fast caching instances using F method in ThinkPHP

  • 2021-06-29 10:40:38
  • OfStack

1 File-based caching is generally sufficient, while thinkPHP provides a fast caching method, F, which is designed specifically for file-based caching.
Because PHP method is used, it is more efficient than S method.

The F method has the following characteristics:

1. Simple data cache;
2. Save in file form;
3. Load the cache using PHP return data;
4. Support subdirectory caching and automatic creation;
5. Support deletion of cache and bulk deletion;

$path="../Public/Runtime/";
$str="fastrunaaaaaaaaaaaaaaaa";
F("str/ffun",$str,$path);

This places the $str string in the file. /Public/Runtime/str/ffun.php

The file of ffun.php is as follows:

<?php
return 'fastrunaaaaaaaaaaaaaaaa';
?>

Deleting a cache is also easy:

F("str/ffun",NULL);


Related articles: