autocomplete caching
see 7dce8da850d2b266ffc196a9e9c0aa9ee9314fe3
This commit is contained in:
parent
2546621c59
commit
56e5348470
@ -13,21 +13,28 @@ class AutoComplete extends Extension {
|
||||
if(!isset($_GET["s"])) return;
|
||||
|
||||
//$limit = 0;
|
||||
$cache_key = "autocomplete-" . strtolower($_GET["s"]);
|
||||
$limitSQL = "";
|
||||
$SQLarr = array("search"=>$_GET["s"]."%");
|
||||
if(isset($_GET["limit"]) && $_GET["limit"] !== 0){
|
||||
$limitSQL = "LIMIT :limit";
|
||||
$SQLarr['limit'] = $_GET["limit"];
|
||||
$cache_key .= "-" . $_GET["limit"];
|
||||
}
|
||||
|
||||
$res = $database->get_pairs("
|
||||
SELECT tag, count
|
||||
FROM tags
|
||||
WHERE tag LIKE :search
|
||||
AND count > 0
|
||||
ORDER BY count DESC
|
||||
$limitSQL", $SQLarr
|
||||
);
|
||||
$res = null;
|
||||
$database->cache->get($cache_key);
|
||||
if(!$res) {
|
||||
$res = $database->get_pairs("
|
||||
SELECT tag, count
|
||||
FROM tags
|
||||
WHERE tag LIKE :search
|
||||
AND count > 0
|
||||
ORDER BY count DESC
|
||||
$limitSQL", $SQLarr
|
||||
);
|
||||
$database->cache->set($cache_key, $res, 600);
|
||||
}
|
||||
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/json");
|
||||
|
Loading…
x
Reference in New Issue
Block a user