Using remember helper for server side filtering.

Fixing bug where the current page was not cached as well.
parent 9932c908
......@@ -82,22 +82,17 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
*/
public function serverPaginationFilteringFor(Request $request): LengthAwarePaginator
{
$page = $request->get('page');
$order = $request->get('order');
$orderBy = $request->get('order_by');
$perPage = $request->get('per_page');
$search = $request->get('search');
$key = "{$order}-{$orderBy}-{$perPage}-{$search}";
$key = $this->getBaseKey() . "serverPaginationFilteringFor.{$page}-{$order}-{$orderBy}-{$perPage}-{$search}";
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.serverPaginationFilteringFor.{$key}",
$this->cacheTime,
function () use ($request) {
return $this->repository->serverPaginationFilteringFor($request);
}
);
return $this->remember(function () use ($request) {
return $this->repository->serverPaginationFilteringFor($request);
}, $key);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment