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
+8 -11
View File
@@ -10,6 +10,7 @@ use App\Models\Type;
use App\Repositories\Group\GroupRepositoryInterface;
use App\Repositories\Log\LogRepositoryInterface;
use Illuminate\Http\Request;
use App\Support\Cache\CacheKey;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -154,23 +155,19 @@ class GroupController extends Controller
/**
* Clear all group and product-related caches
*/
private function clearGroupCaches($typeId)
private function clearGroupCaches($typeId): void
{
// Clear general shop caches
Cache::forget('shop_types_with_groups');
Cache::forget(CacheKey::build('group', 'shop-types'));
if ($typeId) {
// Clear type-specific group cache
Cache::forget("groups_type_{$typeId}");
// Clear all product caches for this type
Cache::forget(CacheKey::build('group', 'by-type', ['type_id' => $typeId]));
$groups = $this->groupRepository->filter(['type_id' => $typeId]);
foreach ($groups as $group) {
Cache::forget("products_type_{$typeId}_group_{$group->id}");
Cache::forget(CacheKey::build('group', 'products', ['type_id' => $typeId, 'group_id' => $group->id]));
if ($group->slug) {
// Clear paginated product caches for multiple pages
for ($page = 1; $page <= 10; $page++) {
Cache::forget("group_products_{$group->slug}_page_{$page}");
Cache::forget(CacheKey::build('group', 'slug-products', ['page' => $page, 'slug' => $group->slug]));
}
}
}