【发布时间】:2016-12-20 00:14:50
【问题描述】:
这是我在 index.php 文件中的主要查询
我正在尝试使用phpfastcache 缓存此查询
$shorting = $conn->prepare("SELECT text,time FROM small WHERE active='0' ORDER BY time DESC LIMIT 10");
$shorting->execute();
while($obj = $shorting->fetch(PDO::FETCH_OBJ)){
<div id="lastnews_title">
<div><?php echo $obj->text; ?></div>
<div style="text-align:left">
<?php echo timeTonow($obj->time); ?>
</div>
这是 phpfastcache 站点中的一个示例
// Require Library
require_once("../phpfastcache/phpfastcache.php");
// simple Caching with:
$cache = phpFastCache();
// Try to get $products from Caching First
// product_page is "identity keyword";
$products = $cache->get("product_page");
if($products == null) {
$products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS";
// Write products to Cache in 10 minutes with same keyword
$cache->set("product_page",$products , 600);
}
// use your products here or return it;
echo $products;
我在 index.php 中写 require_once("../phpfastcache/phpfastcache.php");
我不知道如何在这个缓存类中插入我的查询?
抱歉英语不好
【问题讨论】: