1
0
Эх сурвалжийг харах

Update ApiV1Controller, fix empty public timeline bug

Daniel Supernault 3 жил өмнө
parent
commit
0584f9ee95

+ 5 - 3
app/Http/Controllers/Api/ApiV1Controller.php

@@ -1486,9 +1486,11 @@ class ApiV1Controller extends Controller
 		$limit = $request->input('limit') ?? 3;
 		$user = $request->user();
 
-		if(PublicTimelineService::count() == 0) {
-        	PublicTimelineService::warmCache(true, 400);
-        }
+		Cache::remember('api:v1:timelines:public:cache_check', 3600, function() {
+			if(PublicTimelineService::count() == 0) {
+	        	PublicTimelineService::warmCache(true, 400);
+	        }
+		});
 
         if ($max) {
 			$feed = PublicTimelineService::getRankedMaxId($max, $limit);

+ 4 - 4
app/Services/PublicTimelineService.php

@@ -48,10 +48,10 @@ class PublicTimelineService {
 
 	public static function add($val)
 	{
-		return;
-
-		if(config('database.redis.client') === 'phpredis' && self::count() > 400) {
-			Redis::zpopmin(self::CACHE_KEY);
+		if(self::count() > 400) {
+			if(config('database.redis.client') === 'phpredis') {
+				Redis::zpopmin(self::CACHE_KEY);
+			}
 		}
 
 		return Redis::zadd(self::CACHE_KEY, $val, $val);