thinkphp static cache, data cache, fast cache, query cache

Source: Internet
Author: User
Tags delete cache

Static caching

' Html_path ' cache directory, which is a constant is not a configuration item, defined in the portal file

' html_cache_on ' = = True, //Turn on static cache

' Html_cache_time ' + 3600, //global static cache lifetime (seconds)

' Html_file_suffix ' = '. HTML ', //Set static cache file suffix

' html_cache_rules ' = = Array ( //define static cache rules

Define the entire article controller

' article: ' = ' = ' article/{:action}_{id} ',

To cache a product

' product:plist ' = ' product/plist_{id}_{pid} ',

To cache a single operation

' Index:index ' = ' index/index ',

' Product:category ' =>array (' Product/category ', 0),

),

//------------------------------------------------------------

---------------------data cache (Universal cache)--------------------

Query cache, Fast cache

Data caching

Cached files in Runtime/temp

' Data_cache_type ' = ' File ',

' Data_cache_prefix ' = ' kangku_ ',

' data_cache_time ' =

//------------------------------------------------------------

-----------------------Fast Cache-----------------------------

Persistent cache

Cache data

F (' data ', $Data);

Specify directory default Data_path

F (' Data ', $Data, Temp_path);

Delete Cache

F (' data ', NULL);

//------------------------------------------------------------

-----------------------Query Cache-----------------------------

Cache at query time

Add the cache (true) after the first query and then take the value from the cached data, no other judgment

1. Default cache

$Model->cache (True)->where (' Status=1 ')->select ();

2. Give the cache a name that can be read

$Model->cache (' Cache_name ')->select ();

Read value

$value = S (' Cache_name ');

3. Set the cache mode and time

$Model->cache (true,60, ' file ')->select ();

//------------------------------------------------------------

--------------------SQL parsing Cache-----------------------------

Turn on caching

' Db_sql_build_cache ' = true,

Cache mode

' Db_sql_build_queue ' = ' file ',

Queue Length for SQL cache

' Db_sql_build_length ' = 20,

thinkphp static cache, data cache, fast cache, query cache

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.