mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 17:26:43 +00:00
Update ApiController
This commit is contained in:
parent
5379c462bf
commit
d78f7c7734
1 changed files with 8 additions and 2 deletions
|
@ -9,8 +9,7 @@ use App\{
|
||||||
Profile,
|
Profile,
|
||||||
UserFilter
|
UserFilter
|
||||||
};
|
};
|
||||||
use Auth;
|
use Auth, Cache, Redis;
|
||||||
use Cache;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Services\SuggestionService;
|
use App\Services\SuggestionService;
|
||||||
|
|
||||||
|
@ -71,6 +70,13 @@ class ApiController extends BaseApiController
|
||||||
->pluck('filterable_id')->toArray();
|
->pluck('filterable_id')->toArray();
|
||||||
$following = array_merge($following, $filters);
|
$following = array_merge($following, $filters);
|
||||||
|
|
||||||
|
$key = config('cache.prefix').':api:local:exp:rec:'.$id;
|
||||||
|
$ttl = (int) Redis::ttl($key);
|
||||||
|
|
||||||
|
if($request->filled('refresh') == true && (290 > $ttl) == true) {
|
||||||
|
Cache::forget('api:local:exp:rec:'.$id);
|
||||||
|
}
|
||||||
|
|
||||||
$res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) {
|
$res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) {
|
||||||
return Profile::select(
|
return Profile::select(
|
||||||
'id',
|
'id',
|
||||||
|
|
Loading…
Reference in a new issue