In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to update the commodity list regularly with php script". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
In order to improve the anti-concurrency ability in e-commerce projects, you need to cache the list of items. Here is the script used to update the cache:
/ / the temporary key//PRODUCTION where PRODUCTION_ is cached merchandise list is cached merchandise list key$con = mysqli_connect ($db_config ['host'], $db_config [' user'], $db_config ['passwd'], $db_config [' database']); $redis = new Redis (); $redis- > connect ($redis_config ['host']); $redis- > del (PRODUCTION_); $sql = "select * from production ORDER BY created_at"; $result = mysqli_query ($con,$sql); $artimages = [] While ($row = mysqli_fetch_assoc ($result)) {$redis- > lPush (PRODUCTION_,json_encode ($row));} / * * is not directly updated to the item list because the script takes a long time to execute when the amount of data in the item list is large. * after del PRODUCTION, users will not be able to read the product list when they visit the website before lPush PRODUCTION. * save the temporary list first, and then the rename is the key*/$redis- > rename (PRODUCTION_,PRODUCTION) of the actual query.
The appeal script is just a demo, which needs to be locked in the actual application, otherwise it will make an error when the script is not finished and the next automatic execution of crontab comes.
The following is the crontab script:
* root / usr/local/php/bin/php / xxx/xxxx/xxx/production.php > / dev/null 2 > & 1root is the user / usr/local/php/bin/php php script interpreter that executes the script. If you don't write the full path, you will get an error > / dev/null 2 > & 1 ignore the log output "how to use php script to update the product list regularly". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.