1
0
Fork 0

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
1 changed files with 3 additions and 2 deletions

View File

@ -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;
});
}