浏览代码

Merge pull request #4772 from pixelfed/staging

Update HashtagService, improve count perf
daniel 1 年之前
父节点
当前提交
23dea20024
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 3 0
      CHANGELOG.md
  2. 3 2
      app/Services/HashtagService.php

+ 3 - 0
CHANGELOG.md

@@ -51,6 +51,9 @@
 - Update mail config ([0e431271](https://github.com/pixelfed/pixelfed/commit/0e431271))
 - Update hashtag following ([015b1b80](https://github.com/pixelfed/pixelfed/commit/015b1b80))
 - Update IncrementPostCount job, prevent overlap ([b2c9cc23](https://github.com/pixelfed/pixelfed/commit/b2c9cc23))
+- Update HashtagFollowService, fix cache invalidation bug ([84f4e885](https://github.com/pixelfed/pixelfed/commit/84f4e885))
+- Update Experimental Home Feed, fix remote posts, shares and reblogs ([c6a6b3ae](https://github.com/pixelfed/pixelfed/commit/c6a6b3ae))
+- Update HashtagService, improve count perf ([3327a008](https://github.com/pixelfed/pixelfed/commit/3327a008))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)

+ 3 - 2
app/Services/HashtagService.php

@@ -29,8 +29,9 @@ class HashtagService
 
     public static function count($id)
     {
-        return Cache::remember('services:hashtag:public-count:by_id:' . $id, 86400, function() use($id) {
-            return StatusHashtag::whereHashtagId($id)->whereStatusVisibility('public')->count();
+        return Cache::remember('services:hashtag:public-count:by_id:' . $id, 3600, function() use($id) {
+            $tag = Hashtag::find($id);
+            return $tag ? $tag->cached_count ?? 0 : 0;
         });
     }