caching for autocomplete
This commit is contained in:
parent
79648b04d2
commit
7dce8da850
@ -49,20 +49,27 @@ class TagList extends Extension {
|
|||||||
if(!isset($_GET["s"])) return;
|
if(!isset($_GET["s"])) return;
|
||||||
|
|
||||||
//$limit = 0;
|
//$limit = 0;
|
||||||
|
$cache_key = "autocomplete-" . strtolower($_GET["s"]);
|
||||||
$limitSQL = "";
|
$limitSQL = "";
|
||||||
$SQLarr = array("search"=>$_GET["s"]."%");
|
$SQLarr = array("search"=>$_GET["s"]."%");
|
||||||
if(isset($_GET["limit"]) && $_GET["limit"] !== 0){
|
if(isset($_GET["limit"]) && $_GET["limit"] !== 0){
|
||||||
$limitSQL = "LIMIT :limit";
|
$limitSQL = "LIMIT :limit";
|
||||||
$SQLarr['limit'] = $_GET["limit"];
|
$SQLarr['limit'] = $_GET["limit"];
|
||||||
|
$cache_key .= "-" . $_GET["limit"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $database->get_col($database->scoreql_to_sql("
|
$res = null;
|
||||||
SELECT tag
|
$database->cache->get($cache_key);
|
||||||
FROM tags
|
if(!$res) {
|
||||||
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search)
|
$res = $database->get_col($database->scoreql_to_sql("
|
||||||
AND count > 0
|
SELECT tag
|
||||||
$limitSQL
|
FROM tags
|
||||||
"), $SQLarr);
|
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search)
|
||||||
|
AND count > 0
|
||||||
|
$limitSQL
|
||||||
|
"), $SQLarr);
|
||||||
|
$database->cache->set($cache_key, $res, 600);
|
||||||
|
}
|
||||||
|
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
$page->set_type("text/plain");
|
$page->set_type("text/plain");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user