The thinkphp F method can only be used to cache simple data types and does not support expiration and cache objects. The S () cache method supports the validity period, also known as the dynamic caching method, using the following example:
. The code is as follows:
Cache $data data using the data identity
S (' data ', $Data); The front is the cache flag, followed by the cached data
. The code is as follows:
Cache $data data for 3,600 seconds
S (' Data ', $Data, 3600);
. The code is as follows:
Delete cached data
S (' data ', NULL); The first parameter when the cached identity name
. The code is as follows:
$cache =s ($cachename);//Set Cache flag
Determine if you have this query cache
if (! $cache) {//$cache is the cache identifier (each query corresponds to a cache that has different caches for different queries)
$cache = $video->where ($map)->order ($order)->limit ($limit)->select ();
foreach ($cache as $key = = $value) {
$userlist = $user->where ("id=". $value [' user_id '])->find ();
$cache [$key] ["nickname"]= $userlist [' nickname '];
}
S ($cachename, $cache, 3600); Setting the cache lifetime
}
S ($cachename, NULL); Delete Cache
The above describes the thinkphp cache method s overview, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.