]> git.mxchange.org Git - friendica.git/blobdiff - include/socgraph.php
Merge pull request #2975 from annando/1611-frontend-worker
[friendica.git] / include / socgraph.php
index a41861d6eae0b33978797ad63fc5c201b3b0cc1c..421a68cc9ef9212aad785505f179c2814cec5dab 100644 (file)
@@ -1075,8 +1075,16 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) {
 
 function suggestion_query($uid, $start = 0, $limit = 80) {
 
-       if(! $uid)
+       if (!$uid) {
                return array();
+       }
+
+// Uncommented because the result of the queries are to big to store it in the cache.
+// We need to decide if we want to change the db column type or if we want to delete it.
+//     $list = Cache::get("suggestion_query:".$uid.":".$start.":".$limit);
+//     if (!is_null($list)) {
+//             return $list;
+//     }
 
        $network = array(NETWORK_DFRN);
 
@@ -1087,9 +1095,10 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
                $network[] = NETWORK_OSTATUS;
 
        $sql_network = implode("', '", $network);
-       //$sql_network = "'".$sql_network."', ''";
        $sql_network = "'".$sql_network."'";
 
+       /// @todo This query is really slow
+       // By now we cache the data for five minutes
        $r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
                INNER JOIN `glink` ON `glink`.`gcid` = `gcontact`.`id`
                where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
@@ -1108,8 +1117,13 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
                intval($limit)
        );
 
-       if(count($r) && count($r) >= ($limit -1))
+       if (count($r) && count($r) >= ($limit -1)) {
+// Uncommented because the result of the queries are to big to store it in the cache.
+// We need to decide if we want to change the db column type or if we want to delete it.
+//             Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES);
+
                return $r;
+       }
 
        $r2 = q("SELECT gcontact.* FROM gcontact
                INNER JOIN `glink` ON `glink`.`gcid` = `gcontact`.`id`
@@ -1138,6 +1152,9 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
        while (sizeof($list) > ($limit))
                array_pop($list);
 
+// Uncommented because the result of the queries are to big to store it in the cache.
+// We need to decide if we want to change the db column type or if we want to delete it.
+//     Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, CACHE_FIVE_MINUTES);
        return $list;
 }