diff --git a/source/Internal/Framework/Cache/Command/ClearCacheCommand.php b/source/Internal/Framework/Cache/Command/ClearCacheCommand.php
index 3860abd047f..79f2b43b5e5 100644
--- a/source/Internal/Framework/Cache/Command/ClearCacheCommand.php
+++ b/source/Internal/Framework/Cache/Command/ClearCacheCommand.php
@@ -9,11 +9,8 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Cache\Command;
-use OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\ItemPoolFactoryInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\ShopPoolFactoryInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Service\ContainerCacheInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
-use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -22,12 +19,9 @@
class ClearCacheCommand extends Command
{
public function __construct(
- private readonly ShopAdapterInterface $shopAdapter,
- private readonly ShopTemplateCacheServiceInterface $shopTemplateCacheService,
private readonly ContainerCacheInterface $containerCache,
private readonly ContextInterface $context,
- private readonly ItemPoolFactoryInterface $itemPoolFactory,
- private readonly ShopPoolFactoryInterface $shopPoolFactory
+ private readonly ShopCacheCleanerInterface $shopCacheCleaner,
) {
parent::__construct();
}
@@ -39,19 +33,11 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
- $this->shopTemplateCacheService->invalidateAllShopsCache();
- $this->shopAdapter->invalidateModulesCache();
-
+ $this->shopCacheCleaner->clearAll();
foreach ($this->context->getAllShopIds() as $shopId) {
$this->containerCache->invalidate($shopId);
-
- $this
- ->shopPoolFactory
- ->create($this->itemPoolFactory->create($shopId))
- ->invalidate($shopId);
}
-
- $output->writeln("Cleared cache files");
+ $output->writeln('Cleared cache files');
return 0;
}
diff --git a/source/Internal/Framework/Cache/Pool/ItemPoolFactoryInterface.php b/source/Internal/Framework/Cache/Pool/CacheItemPoolFactoryInterface.php
similarity index 73%
rename from source/Internal/Framework/Cache/Pool/ItemPoolFactoryInterface.php
rename to source/Internal/Framework/Cache/Pool/CacheItemPoolFactoryInterface.php
index 55d36b6abd6..88c032642be 100644
--- a/source/Internal/Framework/Cache/Pool/ItemPoolFactoryInterface.php
+++ b/source/Internal/Framework/Cache/Pool/CacheItemPoolFactoryInterface.php
@@ -9,9 +9,7 @@
use Psr\Cache\CacheItemPoolInterface;
-interface ItemPoolFactoryInterface
+interface CacheItemPoolFactoryInterface
{
public function create(int $shopId): CacheItemPoolInterface;
-
- public function createForCurrentShop(): CacheItemPoolInterface;
-}
\ No newline at end of file
+}
diff --git a/source/Internal/Framework/Cache/Pool/ItemPoolFactory.php b/source/Internal/Framework/Cache/Pool/FilesystemCacheItemPoolFactory.php
similarity index 56%
rename from source/Internal/Framework/Cache/Pool/ItemPoolFactory.php
rename to source/Internal/Framework/Cache/Pool/FilesystemCacheItemPoolFactory.php
index fb9adca06be..34817e9c06e 100644
--- a/source/Internal/Framework/Cache/Pool/ItemPoolFactory.php
+++ b/source/Internal/Framework/Cache/Pool/FilesystemCacheItemPoolFactory.php
@@ -12,8 +12,9 @@
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
+use Symfony\Component\Filesystem\Path;
-class ItemPoolFactory implements ItemPoolFactoryInterface
+class FilesystemCacheItemPoolFactory implements CacheItemPoolFactoryInterface
{
public function __construct(private readonly ContextInterface $context)
{
@@ -22,16 +23,8 @@ public function __construct(private readonly ContextInterface $context)
public function create(int $shopId): CacheItemPoolInterface
{
return new FilesystemAdapter(
- namespace: ShopPoolNameFactory::get($shopId),
- directory: $this->context->getCacheDirectory()
+ namespace: "cache_items_shop_$shopId",
+ directory: Path::join($this->context->getCacheDirectory(), 'pool',)
);
}
-
- public function createForCurrentShop(): CacheItemPoolInterface
- {
- return new FilesystemAdapter(
- namespace: ShopPoolNameFactory::get($this->context->getCurrentShopId()),
- directory: $this->context->getCacheDirectory()
- );
- }
-}
\ No newline at end of file
+}
diff --git a/source/Internal/Framework/Cache/Pool/ShopPoolFactory.php b/source/Internal/Framework/Cache/Pool/ShopPoolFactory.php
deleted file mode 100644
index 0fff927b527..00000000000
--- a/source/Internal/Framework/Cache/Pool/ShopPoolFactory.php
+++ /dev/null
@@ -1,28 +0,0 @@
-shopAdapter, $this->templateCacheService);
- }
-}
\ No newline at end of file
diff --git a/source/Internal/Framework/Cache/Pool/ShopPoolFactoryInterface.php b/source/Internal/Framework/Cache/Pool/ShopPoolFactoryInterface.php
deleted file mode 100644
index 2db6ed23cc8..00000000000
--- a/source/Internal/Framework/Cache/Pool/ShopPoolFactoryInterface.php
+++ /dev/null
@@ -1,15 +0,0 @@
- static::$namePrefix . $id,
- $shopIds
- );
- }
-}
\ No newline at end of file
diff --git a/source/Internal/Framework/Cache/Pool/ShopPoolService.php b/source/Internal/Framework/Cache/Pool/ShopPoolService.php
deleted file mode 100644
index 49496f5cce2..00000000000
--- a/source/Internal/Framework/Cache/Pool/ShopPoolService.php
+++ /dev/null
@@ -1,31 +0,0 @@
-templateCacheService->invalidateCache($shopId);
- $this->shopAdapter->invalidateModulesCache();
- $this->cacheItemPool->clear();
- }
-}
\ No newline at end of file
diff --git a/source/Internal/Framework/Cache/Pool/ShopPoolServiceInterface.php b/source/Internal/Framework/Cache/Pool/ShopPoolServiceInterface.php
deleted file mode 100644
index d106a310775..00000000000
--- a/source/Internal/Framework/Cache/Pool/ShopPoolServiceInterface.php
+++ /dev/null
@@ -1,13 +0,0 @@
-shopAdapter->invalidateModulesCache();
+ $this->templateCacheService->invalidateCache($shopId);
+ $this->cacheItemPoolFactory->create($shopId)->clear();
+ }
+
+ public function clearAll(): void
+ {
+ $this->shopAdapter->invalidateModulesCache();
+ $this->templateCacheService->invalidateAllShopsCache();
+ foreach ($this->context->getAllShopIds() as $shopId) {
+ $this->cacheItemPoolFactory->create($shopId)->clear();
+ }
+ }
+}
diff --git a/source/Internal/Framework/Cache/services.yaml b/source/Internal/Framework/Cache/services.yaml
index 33b21b69ee8..f3645607201 100644
--- a/source/Internal/Framework/Cache/services.yaml
+++ b/source/Internal/Framework/Cache/services.yaml
@@ -1,3 +1,11 @@
imports:
- { resource: Pool/services.yaml }
- { resource: Command/services.yaml }
+
+services:
+ _defaults:
+ autowire: true
+
+ OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface:
+ class: OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheFacade
+ public: true
diff --git a/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php b/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php
index 7346f3942ac..30433fe6d40 100644
--- a/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php
+++ b/source/Internal/Framework/Module/Cache/InvalidateModuleCacheEventSubscriber.php
@@ -9,7 +9,7 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Module\Cache;
-use OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\ShopPoolServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Event\ModuleConfigurationChangedEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\FinalizingModuleActivationEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\FinalizingModuleDeactivationEvent;
@@ -18,13 +18,13 @@
class InvalidateModuleCacheEventSubscriber implements EventSubscriberInterface
{
- public function __construct(private readonly ShopPoolServiceInterface $shopPoolService)
+ public function __construct(private readonly ShopCacheCleanerInterface $shopCacheCleaner)
{
}
public function invalidateModuleCache(ModuleSetupEvent|ModuleConfigurationChangedEvent $event): void
{
- $this->shopPoolService->invalidate($event->getShopId());
+ $this->shopCacheCleaner->clear($event->getShopId());
}
public static function getSubscribedEvents(): array
diff --git a/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php b/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php
index e8bdcf10508..a254adf6993 100644
--- a/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php
+++ b/source/Internal/Framework/Theme/Command/ThemeActivateCommand.php
@@ -9,10 +9,8 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Theme\Command;
-use OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\ShopPoolServiceInterface;
-use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
+use OxidEsales\EshopCommunity\Internal\Framework\Cache\ShopCacheCleanerInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
-use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -26,9 +24,7 @@ class ThemeActivateCommand extends Command
public function __construct(
private readonly ShopAdapterInterface $shopAdapter,
- private readonly ShopTemplateCacheServiceInterface $shopTemplateCacheService,
- private readonly ShopPoolServiceInterface $shopPoolService,
- private readonly BasicContextInterface $context
+ private readonly ShopCacheCleanerInterface $shopCacheCleaner,
) {
parent::__construct();
}
@@ -59,8 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$this->shopAdapter->activateTheme($themeId);
- $this->shopPoolService->invalidate($this->context->getCurrentShopId());
- $this->shopTemplateCacheService->invalidateAllShopsCache();
+ $this->shopCacheCleaner->clearAll();
$output->writeLn('' . sprintf(self::MESSAGE_THEME_ACTIVATED, $themeId) . '');
return Command::SUCCESS;