58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\VPS;
|
|
|
|
use App\Repositories\BaseCachedRepository;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class VPSCachedRepository extends BaseCachedRepository implements VPSRepositoryInterface
|
|
{
|
|
public function __construct(
|
|
public VPSRepository $vPSRepository
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
public function getModel()
|
|
{
|
|
return $this->vPSRepository->getModel();
|
|
}
|
|
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
|
{
|
|
$cacheKey = $this->getCacheKey(md5(json_encode([
|
|
'filterItem' => [
|
|
'data' => $data,
|
|
'relationships' => $relationships,
|
|
'select' => $select,
|
|
'withCount' => $withCount
|
|
]
|
|
])));
|
|
return Cache::remember($cacheKey, $this->cacheTime, function () use ($data, $relationships, $select, $withCount) {
|
|
return $this->vPSRepository->filter($data, $relationships, $withCount, $select);
|
|
});
|
|
}
|
|
public function findWithRelationships(int $id = 0, array $relationships = [],array $withCount = [], array $withSum = [])
|
|
{
|
|
$cacheKey = $this->getCacheKey(md5(json_encode([
|
|
'findWithRelationships' => [
|
|
'id' => $id,
|
|
'relationships' => $relationships
|
|
]
|
|
])));
|
|
return Cache::remember($cacheKey, $this->cacheTime, function () use ($id, $relationships,$withCount,$withSum) {
|
|
return $this->vPSRepository->findWithRelationships($id, $relationships,$withCount,$withSum);
|
|
});
|
|
}
|
|
|
|
public function createWithOs(array $data, array $osIds = [])
|
|
{
|
|
$this->clearCache();
|
|
return $this->vPSRepository->createWithOs($data, $osIds);
|
|
}
|
|
|
|
public function updateWithOs(int $id, array $data, array $osIds = [])
|
|
{
|
|
$this->clearCache();
|
|
return $this->vPSRepository->updateWithOs($id, $data, $osIds);
|
|
}
|
|
}
|