Update ApiV1Controller, fix empty public timeline bug

This commit is contained in:
Daniel Supernault 2021-09-07 21:07:20 -06:00
parent 00c32360ae
commit 0584f9ee95
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 9 additions and 7 deletions

View File

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

View File

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