mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update ApiV1Controller, fix empty public timeline bug
This commit is contained in:
parent
00c32360ae
commit
0584f9ee95
2 changed files with 9 additions and 7 deletions
|
@ -1486,9 +1486,11 @@ class ApiV1Controller extends Controller
|
||||||
$limit = $request->input('limit') ?? 3;
|
$limit = $request->input('limit') ?? 3;
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
|
Cache::remember('api:v1:timelines:public:cache_check', 3600, function() {
|
||||||
if(PublicTimelineService::count() == 0) {
|
if(PublicTimelineService::count() == 0) {
|
||||||
PublicTimelineService::warmCache(true, 400);
|
PublicTimelineService::warmCache(true, 400);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if ($max) {
|
if ($max) {
|
||||||
$feed = PublicTimelineService::getRankedMaxId($max, $limit);
|
$feed = PublicTimelineService::getRankedMaxId($max, $limit);
|
||||||
|
|
|
@ -48,11 +48,11 @@ class PublicTimelineService {
|
||||||
|
|
||||||
public static function add($val)
|
public static function add($val)
|
||||||
{
|
{
|
||||||
return;
|
if(self::count() > 400) {
|
||||||
|
if(config('database.redis.client') === 'phpredis') {
|
||||||
if(config('database.redis.client') === 'phpredis' && self::count() > 400) {
|
|
||||||
Redis::zpopmin(self::CACHE_KEY);
|
Redis::zpopmin(self::CACHE_KEY);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Redis::zadd(self::CACHE_KEY, $val, $val);
|
return Redis::zadd(self::CACHE_KEY, $val, $val);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue