refactor: implement centralized cache key management and add utility traits for vCenter SSH operations.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Repositories\Addon;
|
||||
|
||||
use App\Repositories\BaseCachedRepository;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class AddonCachedRepository extends BaseCachedRepository implements AddonRepositoryInterface
|
||||
{
|
||||
@@ -12,10 +11,12 @@ class AddonCachedRepository extends BaseCachedRepository implements AddonReposit
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getModel()
|
||||
{
|
||||
return $this->addonRepository->getModel();
|
||||
}
|
||||
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
@@ -23,24 +24,13 @@ class AddonCachedRepository extends BaseCachedRepository implements AddonReposit
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
) {
|
||||
if (
|
||||
$returnQuery ||
|
||||
!empty($data['paginate'])
|
||||
) {
|
||||
return $this->addonRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery);
|
||||
if ($returnQuery || !empty($data['paginate'])) {
|
||||
return $this->addonRepository->filter($data, $relationships, $withCount, $select, $returnQuery);
|
||||
}
|
||||
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'filter' => compact('data', 'relationships', 'withCount', 'select')
|
||||
])));
|
||||
|
||||
return Cache::remember(
|
||||
$cacheKey,
|
||||
$this->cacheTime,
|
||||
fn() =>
|
||||
$this->addonRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery)
|
||||
return $this->rememberFilter(
|
||||
compact('data', 'relationships', 'withCount', 'select'),
|
||||
fn () => $this->addonRepository->filter($data, $relationships, $withCount, $select, $returnQuery)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user