We have already tasted the use of s in the thinkphp, the F system is actually a subset of the function of S, only for the complex data cache, and only support the file mode, does not support the cache useful period, because the use of PHP to compile, so its efficiency is higher than the s, is in what we also call the fast cache compilation.
The characteristics of F-coding are:
complex data caching;
retention of documents;
Take PHP to the data compilation load cache;
Support sub-directory cache and automatically set up;
Support Delete cache and bulk delete;
Write and read cache
F (' Data ', ' test data ');
Copy Code
The tacit approach to retention is data_path (the constant is set in the acquiescence of the equipment located at Runtime_path. ' data/' above), that is, generates a file named Data_path. ' data.php ' cache file.
Value: Ensure that your cache identity is unique and avoid data lid and conflict.
The next time the cache data is read, use:
$Data = F (' Data ');
Copy Code
We can take subdirectories to prepare reservations, for example:
F (' User/data ', $data); Cache Write
F (' User/data '); Read cache
Copy Code
The Data_path will be generated. ' user/data.php ' cache file, if the user subdirectory does not have, it will automatically set up, or can support a multilevel subdirectory, for example:
F (' Level1/level2/data ', $data);
Copy Code
If the requirement specifies the port directory of the cache, it can be compiled with the above:
F (' Data ', $data, Temp_path);
Copy Code
When you get it, you need to use:
F (' Data ', ', temp_path);
Copy Code
Delete Cache
Deleting a cache is also complex, using:
F (' data ', NULL);
Copy Code
The second parameter is passed in null, which implies that the data cache is deleted that is identified as data.
Support the bulk deletion function, especially for the picture of the subdirectory cache, assuming we want to delete all cache data on the user subdirectory, you can use:
F (' user/* ', NULL);
Copy Code
or delete using filter conditions, for example:
F (' user/[^a]* ', NULL);
Copy Code
CLS CC International Publication
thinkphp function: F method