Memcached结果= 0

时间:2017-04-02 12:42:35

标签: php memcached

我的源代码

if (location.hash)
{
    var requested_hash = location.hash.slice(1);
    location.hash = '';
    location.hash = requested_hash;
}

我试试这是这个核心? :

if ($where != "")
        $where = "WHERE $where";

$res = $mysqli->query("SELECT COUNT(id) FROM torrents $where LIMIT 1") or die(mysql_error());
$row = mysqli_fetch_array($res);
$count = $row[0];

结果“抱歉找不到”

1 个答案:

答案 0 :(得分:0)

if ($where != "")
      $where = "WHERE $where";
  $res = mysql_query("SELECT COUNT(id) FROM torrents $where LIMIT 100") or die(mysql_error());
$key = md5($res);
$get_data = $memcache->get($key);

if($get_data) {
 echo 'Data Pulled From Cache';
} else {
   while ($row = mysql_fetch_array($res)) {
       $memcache->set($key, $res, TRUE, 3600); 
       $count = $row[0];
 }
}

虽然解决了我的问题