In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use the s method in thinkphp". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the s method in thinkphp.
The s method in thinkphp supports validity, also known as dynamic caching, using methods such as "S ('data',$Data); S (' data',$Data,3600); S ('data',NULL)."
This article operating environment: Windows7 system, thinkphp v5.1, Dell G3 computer.
How to use the s method in thinkphp?
Overview of ThinkPHP caching method S ()
ThinkPHP's F method can only be used to cache simple data types and does not support validity and cache objects. S () caching method supports validity period, also known as dynamic caching method. Examples are as follows:
The code is as follows:
/ / use the data identity to cache $Data data S ('data',$Data); / / the front is the cache tag, followed by the cache data code is as follows: / / cache $Data data for 3600 seconds S (' data',$Data,3600); the code is as follows: / / delete the cached data S ('data',NULL); / / the cached ID code for the first parameter is as follows: $cache=S ($cachename) / / set the cache tag / / determine whether there is this query cache if (! $cache) {/ / $cache (each query corresponds to a cache, that is, different queries have different caches) $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); / / set the lifetime of the cache} S ($cachename,NULL); / / delete the cache here, I believe you have a better understanding of "how to use the s method in thinkphp", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.