mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-22 10:08:31 -05:00
update: use cache()->flexible() to improve response times
This commit is contained in:
@@ -109,7 +109,7 @@ class QuickSearchController extends Controller
|
||||
$searchQuery = fn () => $client->multiSearch($searchQueries, ((new MultiSearchFederation()))->setLimit(20));
|
||||
|
||||
if (preg_match("/^[a-zA-Z0-9-_ .'@:\\[\\]+&\\/,!#()?\"]{1,2}$/", $query)) {
|
||||
$multiSearchResults = cache()->remember('quick-search:'.strtolower($query), 3600 * 24, $searchQuery);
|
||||
$multiSearchResults = cache()->flexible('quick-search:'.strtolower($query), [3600 * 24, 3600 * 24 * 2], $searchQuery);
|
||||
} else {
|
||||
$multiSearchResults = $searchQuery();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class TorrentController extends BaseController
|
||||
*/
|
||||
public function index(): TorrentsResource
|
||||
{
|
||||
$torrents = cache()->remember('torrent-api-index', 300, function () {
|
||||
$torrents = cache()->flexible('torrent-api-index', [60 * 5, 60 * 6], function () {
|
||||
$torrents = Torrent::with(
|
||||
['user:id,username', 'category', 'type', 'resolution', 'region', 'distributor', 'files']
|
||||
)
|
||||
@@ -567,7 +567,7 @@ class TorrentController extends BaseController
|
||||
$cacheKey = $url.'?'.$queryString;
|
||||
|
||||
/** @phpstan-ignore method.unresolvableReturnType (phpstan is unable to resolve type because it's returning a phpstan-ignored line) */
|
||||
[$torrents, $hasMore] = cache()->remember($cacheKey, 300, function () use ($request, $isSqlAllowed) {
|
||||
[$torrents, $hasMore] = cache()->flexible($cacheKey, [60 * 5, 60 * 6], function () use ($request, $isSqlAllowed) {
|
||||
$eagerLoads = fn (Builder $query) => $query
|
||||
->with(['user:id,username', 'category', 'type', 'resolution', 'distributor', 'region', 'files'])
|
||||
->select('*')
|
||||
|
||||
Reference in New Issue
Block a user