diff --git a/vendor/magento/module-configurable-product/Model/Plugin/Frontend/UsedProductsCache.php b/vendor/magento/module-configurable-product/Model/Plugin/Frontend/UsedProductsCache.php index 19a1b8d3ca17..5bb63cac1162 100644 --- a/vendor/magento/module-configurable-product/Model/Plugin/Frontend/UsedProductsCache.php +++ b/vendor/magento/module-configurable-product/Model/Plugin/Frontend/UsedProductsCache.php @@ -24,6 +24,11 @@ */ class UsedProductsCache { + /** + * Default cache life time: 1 year + */ + private const DEFAULT_CACHE_LIFE_TIME = 31536000; + /** * @var MetadataPool */ @@ -49,25 +54,33 @@ class UsedProductsCache */ private $customerSession; + /** + * @var int + */ + private $cacheLifeTime; + /** * @param MetadataPool $metadataPool * @param FrontendInterface $cache * @param SerializerInterface $serializer * @param ProductInterfaceFactory $productFactory * @param Session $customerSession + * @param int $cacheLifeTime */ public function __construct( MetadataPool $metadataPool, FrontendInterface $cache, SerializerInterface $serializer, ProductInterfaceFactory $productFactory, - Session $customerSession + Session $customerSession, + int $cacheLifeTime = self::DEFAULT_CACHE_LIFE_TIME ) { $this->metadataPool = $metadataPool; $this->cache = $cache; $this->serializer = $serializer; $this->productFactory = $productFactory; $this->customerSession = $customerSession; + $this->cacheLifeTime = $cacheLifeTime; } /** @@ -183,7 +196,7 @@ function ($item) { Configurable::TYPE_CODE . '_' . $product->getData($metadata->getLinkField()), ] ); - $result = $this->cache->save($data, $cacheKey, $tags); + $result = $this->cache->save($data, $cacheKey, $tags, $this->cacheLifeTime); return (bool) $result; }