久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用PHP緩存MySQL查詢(xún)結(jié)果的最簡(jiǎn)單方法?

The most simple way to cache MySQL query results using PHP?(使用PHP緩存MySQL查詢(xún)結(jié)果的最簡(jiǎn)單方法?)
本文介紹了使用PHP緩存MySQL查詢(xún)結(jié)果的最簡(jiǎn)單方法?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

每次有人登陸我的頁(yè)面 list.php?id=xxxxx 它都會(huì)重新查詢(xún)一些 MySQL 查詢(xún)以返回:

Each time someone lands in my page list.php?id=xxxxx it requeries some MySQL queries to return this:

$ids = array(..,..,..); // not big array - not longer then 50 number records
$thumbs = array(..,..,..); // not big array - not longer then 50 text records
$artdesc = "some text not very long"; // text field

因?yàn)槲覐闹羞M(jìn)行查詢(xún)的數(shù)據(jù)庫(kù)非常大,所以我想將此結(jié)果緩存 24 小時(shí),例如:xxxxx.php 在/cache/目錄中,以便我可以使用如果它存在,它在 include("xxxxx.php") 中.(或txt文件!?,或任何其他方式)

Because the database from which I make the queries is quite big I would like to cache this results for 24h in maybe a file like: xxxxx.php in a /cache/ directory so i can use it in include("xxxxx.php") if it is present. ( or txt files !? , or any other way )

因?yàn)橛蟹浅:?jiǎn)單的數(shù)據(jù),我相信它可以使用幾行 PHP 代碼來(lái)完成,不需要使用 memcached 或其他專(zhuān)業(yè)對(duì)象.

Because there is very simple data I believe it can be done using a few of PHP lines and no need to use memcached or other professional objects.

因?yàn)槲业?PHP 非常有限,有人可以為此任務(wù)放置 PHP 主線(或代碼)嗎?

Becasuse my PHP is very limited can someone just place the PHP main lines ( or code ) for this task ?

我真的會(huì)很感激!

推薦答案

緩存 PHP 數(shù)組非常簡(jiǎn)單:

Caching a PHP array is pretty easy:

file_put_contents($path, '<?php return '.var_export($my_array,true).';?>');

然后你可以把它讀出來(lái):

Then you can read it back out:

if (file_exists($path)) $my_array = include($path);

您可能還想查看提供緩存的 ADOdb內(nèi)部.

這篇關(guān)于使用PHP緩存MySQL查詢(xún)結(jié)果的最簡(jiǎn)單方法?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動(dòng)填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱(chēng) ASC)
主站蜘蛛池模板: 成年视频在线观看福利资源 | 日韩福利片 | 91久久精品一区二区二区 | 欧美精品在线免费观看 | 第一av| 国产一区二区精品在线 | 亚洲国产精品一区二区第一页 | 国产乱码精品一区二区三区忘忧草 | 亚洲欧美日韩精品久久亚洲区 | 91在线| 色就是色欧美 | 综合色婷婷 | 日本一区二区三区四区 | 欧美乱大交xxxxx另类电影 | 亚洲激情自拍偷拍 | 丁香一区二区 | 国产精品一区二区视频 | 欧美日韩在线视频一区二区 | 毛片一级网站 | 国产乱码久久久久久 | 日韩欧美天堂 | 午夜久久久久久久久久一区二区 | 久久极品 | 久草视频观看 | 久久综合一区二区 | 成人精品一区 | 精品乱码一区二区三四区视频 | 国产精品久久久久影院色老大 | 神马久久av| 日韩中文一区 | 国产一区二区不卡 | 人人干天天干 | av一区在线| 成人精品鲁一区一区二区 | 国产精品99久久久精品免费观看 | av不卡一区 | 91影院在线观看 | 欧美a级成人淫片免费看 | 超黄视频网站 | 国产精品久久免费观看 | 国产美女免费视频 |