]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Tag.php
Fallback to database lock if locking fails
[friendica.git] / src / Model / Tag.php
index c661892edf6186f8866f1f4c04f9dc63272a325e..f947b9f898429744b2f427e3dd1fa0fd4619499f 100644 (file)
@@ -462,11 +462,17 @@ class Tag
         * @param integer $uid
         * @param integer $start
         * @param integer $limit
+        * @param integer $last_uriid
         * @return array with URI-ID
         */
-       public static function getURIIdListByTag(string $search, int $uid = 0, int $start = 0, int $limit = 100)
+       public static function getURIIdListByTag(string $search, int $uid = 0, int $start = 0, int $limit = 100, int $last_uriid = 0)
        {
                $condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))", $search, $uid];
+
+               if (!empty($last_uriid)) {
+                       $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $last_uriid]);
+               }
+
                $params = [
                        'order' => ['uri-id' => true],
                        'group_by' => ['uri-id'],
@@ -520,7 +526,7 @@ class Tag
 
                if (DBA::isResult($tagsStmt)) {
                        $tags = DBA::toArray($tagsStmt);
-                       DI::cache()->set('global_trending_tags-' . $period . '-' . $limit, $tags, Duration::HOUR);
+                       DI::cache()->set('global_trending_tags-' . $period . '-' . $limit, $tags, Duration::DAY);
                        return $tags;
                }
 
@@ -563,7 +569,7 @@ class Tag
 
                if (DBA::isResult($tagsStmt)) {
                        $tags = DBA::toArray($tagsStmt);
-                       DI::cache()->set('local_trending_tags-' . $period . '-' . $limit, $tags, Duration::HOUR);
+                       DI::cache()->set('local_trending_tags-' . $period . '-' . $limit, $tags, Duration::DAY);
                        return $tags;
                }