From 8069fa855b108eea0823d6fb694356991a74955b Mon Sep 17 00:00:00 2001 From: pini-girit Date: Sun, 9 May 2021 13:19:51 +0300 Subject: [PATCH 1/6] v1.14.9: Queries optimization for synchronization table --- Model/SynchronisationChecker.php | 2 +- Model/SynchronisationRepository.php | 24 +++++++++++++++++++----- Setup/UpgradeSchema.php | 8 ++++++++ composer.json | 2 +- etc/module.xml | 2 +- marketplace.composer.json | 2 +- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Model/SynchronisationChecker.php b/Model/SynchronisationChecker.php index cd672916..55627116 100644 --- a/Model/SynchronisationChecker.php +++ b/Model/SynchronisationChecker.php @@ -73,6 +73,6 @@ public function isSynchronized($imageName) } } - return $this->synchronisationRepository->getListByImagePath($imageName)->getTotalCount() > 0; + return $this->synchronisationRepository->isSynchronizedImagePath($imageName); } } diff --git a/Model/SynchronisationRepository.php b/Model/SynchronisationRepository.php index 5deffd47..3c457e06 100644 --- a/Model/SynchronisationRepository.php +++ b/Model/SynchronisationRepository.php @@ -2,14 +2,12 @@ namespace Cloudinary\Cloudinary\Model; -use Cloudinary\Cloudinary\Core\SynchroniseAssetsRepositoryInterface; - use Cloudinary\Cloudinary\Api\SynchronisationRepositoryInterface; -use Cloudinary\Cloudinary\Model\SynchronisationFactory; -use Cloudinary\Cloudinary\Model\ResourceModel\Synchronisation\CollectionFactory; + +use Cloudinary\Cloudinary\Core\SynchroniseAssetsRepositoryInterface; use Cloudinary\Cloudinary\Model\ResourceModel\Synchronisation\Collection as SynchronisationCollection; +use Cloudinary\Cloudinary\Model\ResourceModel\Synchronisation\CollectionFactory; -use Magento\Framework\Api\AbstractSimpleObject; use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\SearchCriteriaInterface; @@ -98,6 +96,9 @@ public function getList(SearchCriteriaInterface $searchCriteria) } /** + * @deprecated + * For checking if image path is synchronized, use isSynchronizedImagePath() + * * @param string $imagePath * * @return SearchResultsInterface @@ -109,6 +110,19 @@ public function getListByImagePath($imagePath) return $this->getList($this->searchCriteriaBuilder->create()); } + /** + * @param string $imagePath + * + * @return bool + */ + public function isSynchronizedImagePath($imagePath) + { + return $this->collectionFactory->create() + ->addFieldToFilter('image_path', $imagePath) + ->setPageSize(1) + ->getFirstItem() ? true : false; + } + /** * @param string $imagePath */ diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index 06f2b730..e335e041 100644 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -33,6 +33,14 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con $this->createProductSpinsetMapTable($setup); } + if (version_compare($context->getVersion(), '1.14.9', '<')) { + $setup->getConnection()->addIndex( + $setup->getTable('cloudinary_synchronisation'), + $setup->getIdxName('cloudinary_synchronisation', ['image_path']), + ['image_path'] + ); + } + $setup->endSetup(); } diff --git a/composer.json b/composer.json index f507f251..ba3214c5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "cloudinary/cloudinary-magento2", "description": "Cloudinary Magento 2 Integration.", "type": "magento2-module", - "version": "1.14.8", + "version": "1.14.9", "license": "MIT", "require": { "cloudinary/cloudinary_php": "^1.20.0" diff --git a/etc/module.xml b/etc/module.xml index 87cebd17..fc4a7797 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/marketplace.composer.json b/marketplace.composer.json index 425e670d..c824feeb 100644 --- a/marketplace.composer.json +++ b/marketplace.composer.json @@ -2,7 +2,7 @@ "name": "cloudinary/cloudinary", "description": "Cloudinary Magento 2 Integration.", "type": "magento2-module", - "version": "1.14.8", + "version": "1.14.9", "license": "MIT", "require": { "cloudinary/cloudinary_php": "^1.20.0" From b300712fd85afa22e7bd1b7692680cc5b19fc67b Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 10 May 2021 12:21:13 +0300 Subject: [PATCH 2/6] v1.14.9: Added registry cache to SynchronizationChecker --- Model/SynchronisationChecker.php | 51 ++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/Model/SynchronisationChecker.php b/Model/SynchronisationChecker.php index 55627116..accc272a 100644 --- a/Model/SynchronisationChecker.php +++ b/Model/SynchronisationChecker.php @@ -6,9 +6,15 @@ use Cloudinary\Cloudinary\Core\AutoUploadMapping\AutoUploadConfigurationInterface; use Cloudinary\Cloudinary\Core\ConfigurationInterface; use Cloudinary\Cloudinary\Core\Image\SynchronizationCheck; +use Magento\Framework\Registry; class SynchronisationChecker implements SynchronizationCheck { + /** + * @var string + */ + private $imageNameHash; + /** * @var SynchronisationRepositoryInterface */ @@ -29,30 +35,60 @@ class SynchronisationChecker implements SynchronizationCheck */ private $mediaLibraryMapFactory; + /** + * @var Registry + */ + private $coreRegistry; + /** * @method __construct * @param SynchronisationRepositoryInterface $synchronisationRepository * @param ConfigurationInterface $configuration * @param AutoUploadConfigurationInterface $autoUploadConfiguration * @param MediaLibraryMapFactory $mediaLibraryMapFactory + * @param Registry $coreRegistry */ public function __construct( SynchronisationRepositoryInterface $synchronisationRepository, ConfigurationInterface $configuration, AutoUploadConfigurationInterface $autoUploadConfiguration, - MediaLibraryMapFactory $mediaLibraryMapFactory + MediaLibraryMapFactory $mediaLibraryMapFactory, + Registry $coreRegistry ) { $this->synchronisationRepository = $synchronisationRepository; $this->configuration = $configuration; $this->autoUploadConfiguration = $autoUploadConfiguration; $this->mediaLibraryMapFactory = $mediaLibraryMapFactory; + $this->coreRegistry = $coreRegistry; + } + + /** + * @method cacheResult + * @param bool $result + * @return mixed + */ + private function cacheResult($result) + { + $this->coreRegistry->unregister($this->imageNameHash); + $this->coreRegistry->register($this->imageNameHash, $result); + return $result; } /** - * @param $imageName + * @method cacheResult + * @return mixed + */ + private function getFromCache() + { + return $this->coreRegistry->registry($this->imageNameHash); + } + + /** + * @param string $imageName + * @param bool $refresh * @return bool */ - public function isSynchronized($imageName) + public function isSynchronized($imageName, $refresh = false) { if (!$imageName) { return false; @@ -62,17 +98,22 @@ public function isSynchronized($imageName) return true; } + $this->imageNameHash = hash('sha256', 'cld_sync_check_' . (string) $imageName); + if (!$refresh && ($cacheResult = $this->getFromCache()) !== null) { + return $cacheResult; + } + if ($this->configuration->isEnabledLocalMapping()) { //Look for a match on the mapping table: preg_match('/(cld_[A-Za-z0-9]{13}_).+$/i', $imageName, $cldUniqid); if ($cldUniqid && isset($cldUniqid[1])) { $mapped = $this->mediaLibraryMapFactory->create()->getCollection()->addFieldToFilter("cld_uniqid", $cldUniqid[1])->setPageSize(1)->getFirstItem(); if ($mapped && ($origPublicId = $mapped->getCldPublicId())) { - return true; + return $this->cacheResult(true); } } } - return $this->synchronisationRepository->isSynchronizedImagePath($imageName); + return $this->cacheResult($this->synchronisationRepository->isSynchronizedImagePath($imageName)); } } From 4ff00352d436d9bf265bea46f46e4e5755c98b20 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 10 May 2021 12:27:30 +0300 Subject: [PATCH 3/6] v1.14.9: Added registry cache to SynchronizationChecker --- Model/SynchronisationChecker.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Model/SynchronisationChecker.php b/Model/SynchronisationChecker.php index accc272a..7a380816 100644 --- a/Model/SynchronisationChecker.php +++ b/Model/SynchronisationChecker.php @@ -13,7 +13,7 @@ class SynchronisationChecker implements SynchronizationCheck /** * @var string */ - private $imageNameHash; + private $imageNameCacheKey; /** * @var SynchronisationRepositoryInterface @@ -69,8 +69,8 @@ public function __construct( */ private function cacheResult($result) { - $this->coreRegistry->unregister($this->imageNameHash); - $this->coreRegistry->register($this->imageNameHash, $result); + $this->coreRegistry->unregister($this->imageNameCacheKey); + $this->coreRegistry->register($this->imageNameCacheKey, $result); return $result; } @@ -80,7 +80,7 @@ private function cacheResult($result) */ private function getFromCache() { - return $this->coreRegistry->registry($this->imageNameHash); + return $this->coreRegistry->registry($this->imageNameCacheKey); } /** @@ -98,7 +98,7 @@ public function isSynchronized($imageName, $refresh = false) return true; } - $this->imageNameHash = hash('sha256', 'cld_sync_check_' . (string) $imageName); + $this->imageNameCacheKey = 'cldsynccheckcachekey_' . (string) $imageName; if (!$refresh && ($cacheResult = $this->getFromCache()) !== null) { return $cacheResult; } From 1021bcc5f780330771a49a8343016e1295c49d70 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 10 May 2021 16:25:48 +0300 Subject: [PATCH 4/6] v1.14.9: Queries optimization for synchronization table --- Model/SynchronisationRepository.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Model/SynchronisationRepository.php b/Model/SynchronisationRepository.php index 3c457e06..144bb53d 100644 --- a/Model/SynchronisationRepository.php +++ b/Model/SynchronisationRepository.php @@ -13,6 +13,7 @@ use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Api\SearchResultsInterface; use Magento\Framework\Api\SearchResultsInterfaceFactory; +use Magento\Framework\App\ResourceConnection; class SynchronisationRepository implements SynchronisationRepositoryInterface, SynchroniseAssetsRepositoryInterface { @@ -46,6 +47,11 @@ class SynchronisationRepository implements SynchronisationRepositoryInterface, S */ private $synchronisationFactory; + /** + * @var ResourceConnection + */ + private $connection; + /** * @param FilterBuilder $filterBuilder * @param SearchCriteriaBuilder $searchCriteriaBuilder @@ -60,7 +66,8 @@ public function __construct( CollectionFactory $collectionFactory, SearchResultsInterface $searchResult, SearchResultsInterfaceFactory $searchResultsFactory, - SynchronisationFactory $synchronisationFactory + SynchronisationFactory $synchronisationFactory, + ResourceConnection $resourceConnection ) { $this->filterBuilder = $filterBuilder; $this->searchCriteriaBuilder = $searchCriteriaBuilder; @@ -68,6 +75,7 @@ public function __construct( $this->searchResult = $searchResult; $this->searchResultsFactory = $searchResultsFactory; $this->synchronisationFactory = $synchronisationFactory; + $this->connection = $resourceConnection->getConnection(); } /** @@ -117,10 +125,13 @@ public function getListByImagePath($imagePath) */ public function isSynchronizedImagePath($imagePath) { - return $this->collectionFactory->create() - ->addFieldToFilter('image_path', $imagePath) - ->setPageSize(1) - ->getFirstItem() ? true : false; + return $this->connection->fetchAll($this->connection->select() + ->from( + $this->connection->getTableName("cloudinary_synchronisation"), + ['cloudinary_synchronisation_id'] + ) + ->where('image_path = ?', $imagePath) + ->limit(1)) ? true : false; } /** From 17bb87df1cde8808d20e406c756877b2e7428f9f Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 10 May 2021 17:51:45 +0300 Subject: [PATCH 5/6] v1.14.9: Added registry cache to transformation queries --- Model/Configuration.php | 12 ++++- Model/Transformation.php | 5 +- Plugin/Catalog/Block/Product/ImageFactory.php | 53 +++++++++++++++++-- .../Model/Product/Image/UrlBuilder.php | 50 +++++++++++++++-- 4 files changed, 106 insertions(+), 14 deletions(-) diff --git a/Model/Configuration.php b/Model/Configuration.php index f706ef55..3dcc5347 100644 --- a/Model/Configuration.php +++ b/Model/Configuration.php @@ -170,7 +170,7 @@ class Configuration implements ConfigurationInterface * @param ModuleListInterface $moduleList * @param ProductMetadataInterface $productMetadata * @param CloudinaryLogger $cloudinaryLogger - * @param registry $coreRegistry + * @param Registry $coreRegistry */ public function __construct( ScopeConfigInterface $configReader, @@ -182,7 +182,7 @@ public function __construct( ModuleListInterface $moduleList, ProductMetadataInterface $productMetadata, CloudinaryLogger $cloudinaryLogger, - registry $coreRegistry + Registry $coreRegistry ) { $this->configReader = $configReader; $this->configWriter = $configWriter; @@ -204,6 +204,14 @@ public function getStoreManager() return $this->storeManager; } + /** + * @return Registry + */ + public function getCoreRegistry() + { + return $this->coreRegistry; + } + /** * @return Cloud */ diff --git a/Model/Transformation.php b/Model/Transformation.php index 205842a7..954f53cd 100644 --- a/Model/Transformation.php +++ b/Model/Transformation.php @@ -2,10 +2,9 @@ namespace Cloudinary\Cloudinary\Model; -use Cloudinary\Cloudinary\Model\ResourceModel\Transformation as TransformationResourceModel; -use Cloudinary\Cloudinary\Model\Configuration; -use Cloudinary\Cloudinary\Core\Image\Transformation\Freeform; use Cloudinary\Cloudinary\Core\Image\Transformation as ImageTransformation; +use Cloudinary\Cloudinary\Core\Image\Transformation\Freeform; +use Cloudinary\Cloudinary\Model\ResourceModel\Transformation as TransformationResourceModel; use Magento\Framework\Data\Collection\AbstractDb; use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\Context; diff --git a/Plugin/Catalog/Block/Product/ImageFactory.php b/Plugin/Catalog/Block/Product/ImageFactory.php index 00d2464f..3c1ab7a2 100644 --- a/Plugin/Catalog/Block/Product/ImageFactory.php +++ b/Plugin/Catalog/Block/Product/ImageFactory.php @@ -17,10 +17,16 @@ use Magento\Catalog\Helper\Image as CatalogImageHelper; use Magento\Catalog\Model\Product; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; use Magento\Framework\View\ConfigInterface; class ImageFactory { + /** + * @var string + */ + private $imagePathCacheKey; + /** * @var ObjectManagerInterface */ @@ -76,6 +82,11 @@ class ImageFactory */ private $transformationModel; + /** + * @var Registry + */ + private $coreRegistry; + /** * @param ObjectManagerInterface $objectManager * @param ConfigInterface $presentationConfig @@ -83,6 +94,7 @@ class ImageFactory * @param UrlGenerator $urlGenerator * @param ConfigurationInterface $configuration * @param TransformationFactory $transformationFactory + * @param Registry $coreRegistry */ public function __construct( ObjectManagerInterface $objectManager, @@ -90,7 +102,8 @@ public function __construct( CloudinaryImageFactory $cloudinaryImageFactory, UrlGenerator $urlGenerator, ConfigurationInterface $configuration, - TransformationFactory $transformationFactory + TransformationFactory $transformationFactory, + Registry $coreRegistry ) { $this->objectManager = $objectManager; $this->presentationConfig = $presentationConfig; @@ -101,6 +114,7 @@ public function __construct( $this->dimensions = null; $this->imageFile = null; $this->keepFrame = true; + $this->coreRegistry = $coreRegistry; } /** @@ -120,6 +134,27 @@ private function getStringCustomAttributes(array $attributes) return !empty($result) ? implode(' ', $result) : ''; } + /** + * @method cacheResult + * @param bool $result + * @return mixed + */ + private function cacheResult($result) + { + $this->coreRegistry->unregister($this->imagePathCacheKey); + $this->coreRegistry->register($this->imagePathCacheKey, $result); + return $result; + } + + /** + * @method cacheResult + * @return mixed + */ + private function getFromCache() + { + return $this->coreRegistry->registry($this->imagePathCacheKey); + } + /** * Create image block from product * @@ -177,10 +212,18 @@ function () use ($imageBlock) { } ); - $transformations = $this->transformationModel->addFreeformTransformationForImage( - $this->createTransformation($imageMiscParams), - $imagePath - ); + $this->imagePathCacheKey = 'cldtransformcachekey_' . (string) $imagePath . json_encode($imageMiscParams); + if (($cacheResult = $this->getFromCache()) !== null) { + $transformations = $cacheResult; + } else { + $transformations = $this->cacheResult( + $this->transformationModel->addFreeformTransformationForImage( + $this->createTransformation($imageMiscParams), + $imagePath + ) + ); + } + $generatedImageUrl = $this->urlGenerator->generateFor( $image, $transformations diff --git a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php index 1f921a15..43943d55 100644 --- a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php +++ b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php @@ -14,10 +14,16 @@ use Magento\Catalog\Helper\Image as CatalogImageHelper; use Magento\Catalog\Model\Product\Image\UrlBuilder as CatalogUrlBuilder; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; use Magento\Framework\View\ConfigInterface; class UrlBuilder { + /** + * @var string + */ + private $imagePathCacheKey; + /** * @var ObjectManagerInterface */ @@ -73,6 +79,11 @@ class UrlBuilder */ private $transformationModel; + /** + * @var Registry + */ + private $coreRegistry; + /** * @param ObjectManagerInterface $objectManager * @param ConfigInterface $presentationConfig @@ -98,6 +109,28 @@ public function __construct( $this->dimensions = null; $this->imageFile = null; $this->keepFrame = true; + $this->coreRegistry = $coreRegistry; + } + + /** + * @method cacheResult + * @param bool $result + * @return mixed + */ + private function cacheResult($result) + { + $this->coreRegistry->unregister($this->imagePathCacheKey); + $this->coreRegistry->register($this->imagePathCacheKey, $result); + return $result; + } + + /** + * @method cacheResult + * @return mixed + */ + private function getFromCache() + { + return $this->coreRegistry->registry($this->imagePathCacheKey); } /** @@ -147,12 +180,21 @@ function () use ($url) { } ); + $this->imagePathCacheKey = 'cldtransformcachekey_' . (string) $imagePath . json_encode($imageMiscParams); + if (($cacheResult = $this->getFromCache()) !== null) { + $transformations = $cacheResult; + } else { + $transformations = $this->cacheResult( + $this->transformationModel->addFreeformTransformationForImage( + $this->createTransformation($imageMiscParams), + $imagePath + ) + ); + } + $generatedImageUrl = $this->urlGenerator->generateFor( $image, - $this->transformationModel->addFreeformTransformationForImage( - $this->createTransformation($imageMiscParams), - $imagePath - ) + $transformations ); $url = $generatedImageUrl; From 7085d896fadd38700ca3541141f3f9027df5b5f7 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 10 May 2021 18:01:21 +0300 Subject: [PATCH 6/6] v1.14.9: Removed registry cache from transformation queries - needs improvments --- Plugin/Catalog/Block/Product/ImageFactory.php | 53 ++----------------- .../Model/Product/Image/UrlBuilder.php | 50 ++--------------- 2 files changed, 9 insertions(+), 94 deletions(-) diff --git a/Plugin/Catalog/Block/Product/ImageFactory.php b/Plugin/Catalog/Block/Product/ImageFactory.php index 3c1ab7a2..00d2464f 100644 --- a/Plugin/Catalog/Block/Product/ImageFactory.php +++ b/Plugin/Catalog/Block/Product/ImageFactory.php @@ -17,16 +17,10 @@ use Magento\Catalog\Helper\Image as CatalogImageHelper; use Magento\Catalog\Model\Product; use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\Registry; use Magento\Framework\View\ConfigInterface; class ImageFactory { - /** - * @var string - */ - private $imagePathCacheKey; - /** * @var ObjectManagerInterface */ @@ -82,11 +76,6 @@ class ImageFactory */ private $transformationModel; - /** - * @var Registry - */ - private $coreRegistry; - /** * @param ObjectManagerInterface $objectManager * @param ConfigInterface $presentationConfig @@ -94,7 +83,6 @@ class ImageFactory * @param UrlGenerator $urlGenerator * @param ConfigurationInterface $configuration * @param TransformationFactory $transformationFactory - * @param Registry $coreRegistry */ public function __construct( ObjectManagerInterface $objectManager, @@ -102,8 +90,7 @@ public function __construct( CloudinaryImageFactory $cloudinaryImageFactory, UrlGenerator $urlGenerator, ConfigurationInterface $configuration, - TransformationFactory $transformationFactory, - Registry $coreRegistry + TransformationFactory $transformationFactory ) { $this->objectManager = $objectManager; $this->presentationConfig = $presentationConfig; @@ -114,7 +101,6 @@ public function __construct( $this->dimensions = null; $this->imageFile = null; $this->keepFrame = true; - $this->coreRegistry = $coreRegistry; } /** @@ -134,27 +120,6 @@ private function getStringCustomAttributes(array $attributes) return !empty($result) ? implode(' ', $result) : ''; } - /** - * @method cacheResult - * @param bool $result - * @return mixed - */ - private function cacheResult($result) - { - $this->coreRegistry->unregister($this->imagePathCacheKey); - $this->coreRegistry->register($this->imagePathCacheKey, $result); - return $result; - } - - /** - * @method cacheResult - * @return mixed - */ - private function getFromCache() - { - return $this->coreRegistry->registry($this->imagePathCacheKey); - } - /** * Create image block from product * @@ -212,18 +177,10 @@ function () use ($imageBlock) { } ); - $this->imagePathCacheKey = 'cldtransformcachekey_' . (string) $imagePath . json_encode($imageMiscParams); - if (($cacheResult = $this->getFromCache()) !== null) { - $transformations = $cacheResult; - } else { - $transformations = $this->cacheResult( - $this->transformationModel->addFreeformTransformationForImage( - $this->createTransformation($imageMiscParams), - $imagePath - ) - ); - } - + $transformations = $this->transformationModel->addFreeformTransformationForImage( + $this->createTransformation($imageMiscParams), + $imagePath + ); $generatedImageUrl = $this->urlGenerator->generateFor( $image, $transformations diff --git a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php index 43943d55..1f921a15 100644 --- a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php +++ b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php @@ -14,16 +14,10 @@ use Magento\Catalog\Helper\Image as CatalogImageHelper; use Magento\Catalog\Model\Product\Image\UrlBuilder as CatalogUrlBuilder; use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\Registry; use Magento\Framework\View\ConfigInterface; class UrlBuilder { - /** - * @var string - */ - private $imagePathCacheKey; - /** * @var ObjectManagerInterface */ @@ -79,11 +73,6 @@ class UrlBuilder */ private $transformationModel; - /** - * @var Registry - */ - private $coreRegistry; - /** * @param ObjectManagerInterface $objectManager * @param ConfigInterface $presentationConfig @@ -109,28 +98,6 @@ public function __construct( $this->dimensions = null; $this->imageFile = null; $this->keepFrame = true; - $this->coreRegistry = $coreRegistry; - } - - /** - * @method cacheResult - * @param bool $result - * @return mixed - */ - private function cacheResult($result) - { - $this->coreRegistry->unregister($this->imagePathCacheKey); - $this->coreRegistry->register($this->imagePathCacheKey, $result); - return $result; - } - - /** - * @method cacheResult - * @return mixed - */ - private function getFromCache() - { - return $this->coreRegistry->registry($this->imagePathCacheKey); } /** @@ -180,21 +147,12 @@ function () use ($url) { } ); - $this->imagePathCacheKey = 'cldtransformcachekey_' . (string) $imagePath . json_encode($imageMiscParams); - if (($cacheResult = $this->getFromCache()) !== null) { - $transformations = $cacheResult; - } else { - $transformations = $this->cacheResult( - $this->transformationModel->addFreeformTransformationForImage( - $this->createTransformation($imageMiscParams), - $imagePath - ) - ); - } - $generatedImageUrl = $this->urlGenerator->generateFor( $image, - $transformations + $this->transformationModel->addFreeformTransformationForImage( + $this->createTransformation($imageMiscParams), + $imagePath + ) ); $url = $generatedImageUrl;