refactor: implement centralized cache key management and add utility traits for vCenter SSH operations.

This commit is contained in:
pbao9
2026-05-16 16:52:21 +07:00
parent 06dbd54ecd
commit 8a115c5175
36 changed files with 1694 additions and 517 deletions
@@ -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)