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 ...@@ -82,22 +82,17 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
*/ */
public function serverPaginationFilteringFor(Request $request): LengthAwarePaginator public function serverPaginationFilteringFor(Request $request): LengthAwarePaginator
{ {
$page = $request->get('page');
$order = $request->get('order'); $order = $request->get('order');
$orderBy = $request->get('order_by'); $orderBy = $request->get('order_by');
$perPage = $request->get('per_page'); $perPage = $request->get('per_page');
$search = $request->get('search'); $search = $request->get('search');
$key = "{$order}-{$orderBy}-{$perPage}-{$search}"; $key = $this->getBaseKey() . "serverPaginationFilteringFor.{$page}-{$order}-{$orderBy}-{$perPage}-{$search}";
return $this->cache return $this->remember(function () use ($request) {
->tags([$this->entityName, 'global']) return $this->repository->serverPaginationFilteringFor($request);
->remember( }, $key);
"{$this->locale}.{$this->entityName}.serverPaginationFilteringFor.{$key}",
$this->cacheTime,
function () use ($request) {
return $this->repository->serverPaginationFilteringFor($request);
}
);
} }
/** /**
......
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