thinkphp function: F method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.