示例#1
0
 static function searchPartial($qp, $num, $noCache = false)
 {
     global $wgMemc;
     $howto = strtolower(wfMsg('howto', ''));
     $qp = trim(preg_replace('@(^' . preg_quote($howto) . '|howto)@i', '', strtolower($qp)));
     $cachekey = wfMemcKey('searchpartial', $qp);
     if (!$noCache) {
         $res = $wgMemc->get($cachekey);
     }
     if (is_array($res)) {
         $cached_num = $res['num'];
         if ($cached_num >= $num) {
             unset($res['num']);
             $time += microtime(true);
             return array_slice($res, 0, $num);
         }
     }
     $res = ApiApp::websolrSearch($qp, "json", $num);
     $res = json_decode($res, true);
     $res = $res['response']['docs'];
     // add num to results for use in caching only
     $res['num'] = $num;
     $wgMemc->set($cachekey, $res, 3600);
     unset($res['num']);
     return $res;
 }