Update HashtagService, improve count perf

This commit is contained in:
Daniel Supernault 2023-11-15 23:23:17 -07:00
parent 3e96fa8a56
commit 3327a008fa
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

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