thinkphp Study Notes 01

Source: Internet
Author: User

Categories of caches:

Dynamic caching-The implementation of the underlying mechanism (File, Db, Memchace, Redis) with an interface class to hide implementation details (Cache, Cache.class.php, directory in Thinkphp/library/think).

Database SQL cache

Data dynamic Caching

Static caching

Page static-The static rules that involve caching are, in some cases, how to generate the name of a static cache file, and the time of the cache. When the cache is determined to expire, it is calculated using the generated time of the cache file.

There are two drivers, one is file and the other is SAE.

General issues to consider for caching:

1) When writing, judge whether the cache is open or not. If open, the content is cached.

2) Read the time, to determine whether the cache is still valid, if valid, read out the contents.

Dynamic Cache file Cache:

Each variable exists in its own cache file, supports CRC validation, supports MD5 conversion

Memcache of dynamic cache

Redis for dynamic caching

SQL query cache for dynamic caching

$Model->cache (true,60, ' XCache ')->select (); As long as the cache method is called, $options[' cache ' will be set, and subsequent operations will try to use S () to take a value.

The caches here are also implemented using Think\cache::getinstance.
Select before you check if there is no cache value, if any, you can return directly.
After select, see if there is a need for caching, and if necessary, cache the value.

thinkphp Study Notes 01

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.