refactor: implement centralized cache key management and add utility traits for vCenter SSH operations.
This commit is contained in:
@@ -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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user