refactor: implement centralized cache key management and add utility traits for vCenter SSH operations.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
namespace App\Repositories\Group;
|
||||
|
||||
use App\Repositories\BaseCachedRepository;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Support\Cache\CacheKey;
|
||||
|
||||
class GroupCachedRepository extends BaseCachedRepository implements GroupRepositoryInterface
|
||||
{
|
||||
@@ -21,28 +21,18 @@ class GroupCachedRepository extends BaseCachedRepository implements GroupReposit
|
||||
|
||||
public function getProduct(int $group_id = 0, int $type_id = 0)
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'type_id' => $type_id,
|
||||
'group_id' => $group_id
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($type_id, $group_id) {
|
||||
$cacheKey = CacheKey::build($this->getModuleName(), 'product', ['group_id' => $group_id, 'type_id' => $type_id]);
|
||||
return $this->cache->remember($cacheKey, function () use ($type_id, $group_id) {
|
||||
return $this->groupRepository->getProduct($group_id, $type_id);
|
||||
});
|
||||
}
|
||||
|
||||
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->groupRepository->filter($data, $relationships, $withCount, $select);
|
||||
});
|
||||
return $this->rememberFilter(
|
||||
compact('data', 'relationships', 'withCount', 'select'),
|
||||
fn() => $this->groupRepository->filter($data, $relationships, $withCount, $select)
|
||||
);
|
||||
}
|
||||
|
||||
public function findBySlugWithProduct(string $slug)
|
||||
|
||||
Reference in New Issue
Block a user