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