From 8a47b03a1b21a164e34ad76b15228009b349ec15 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 2 Jul 2019 00:34:28 -0600 Subject: [PATCH] Update StatusHashtagService --- app/Services/StatusHashtagService.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php index 4f876a68..76d0f47e 100644 --- a/app/Services/StatusHashtagService.php +++ b/app/Services/StatusHashtagService.php @@ -18,9 +18,14 @@ class StatusHashtagService { $res = collect([]); $key = self::CACHE_KEY . $id; $stop = $stop > 2000 ? 2000 : $stop; - $ids = Redis::zrangebyscore($key, $start, $stop); + $ids = Redis::zrevrangebyscore($key, $start, $stop); if(empty($ids)) { - $ids = self::coldGet($id, $start, $stop); + if(self::count($id) == 0) { + $ids = self::coldGet($id, 0, 2000); + $ids = $ids->splice($start, $stop); + } else { + $ids = self::coldGet($id, $start, $stop); + } } foreach($ids as $statusId) { $res->push(self::getStatus($statusId, $id));