From fe736f2b4404287f4321e06f9c9059171184f1db Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 10 Sep 2019 22:03:45 -0600 Subject: [PATCH] Update StatusHashtagService, fix count bug --- app/Services/StatusHashtagService.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php index 7c5ed87bb..6107c293b 100644 --- a/app/Services/StatusHashtagService.php +++ b/app/Services/StatusHashtagService.php @@ -56,11 +56,11 @@ class StatusHashtagService { public static function count($id) { - $count = Redis::zcount(self::CACHE_KEY . $id, '-inf', '+inf'); - if(empty($count)) { - $count = StatusHashtag::whereHashtagId($id)->count(); - } - return $count; + $key = 'pf:services:status-hashtag:count:' . $id; + $ttl = now()->addHours(6); + return Cache::remember($key, $ttl, function() use($id) { + return StatusHashtag::whereHashtagId($id)->count(); + }); } public static function getStatus($statusId, $hashtagId)