Skip to content

Commit 9a0e6f0

Browse files
authored
Merge pull request #89 from magento-commerce/MCLOUD-11514
MCLOUD-11514: Add ACSD-56624 patch to cloud patches
2 parents 2340963 + d0bf3c0 commit 9a0e6f0

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

patches.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@
277277
},
278278
"Fixes the issue where missed jobs unnecessarily wait for cron job locks.": {
279279
">=2.4.4 <2.4.7": "MCLOUD-11329__missed_jobs_unnecessarily_wait_for_cron_job_locks__2.4.6.patch"
280+
},
281+
"Enhanced Layout Cache Efficiency (memory usage reduced)": {
282+
">=2.4.4 <2.4.7": "MCLOUD-11514__enhanced_layout_cache_efficiency__2.4.6-p3.patch"
280283
}
281284
},
282285
"magento/module-paypal": {
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
diff --git a/vendor/magento/framework/App/Cache/Type/Layout.php b/vendor/magento/framework/App/Cache/Type/Layout.php
2+
index 2ea069a..57b1cb4 100644
3+
--- a/vendor/magento/framework/App/Cache/Type/Layout.php
4+
+++ b/vendor/magento/framework/App/Cache/Type/Layout.php
5+
@@ -3,6 +3,8 @@
6+
* Copyright © Magento, Inc. All rights reserved.
7+
* See COPYING.txt for license details.
8+
*/
9+
+declare(strict_types=1);
10+
+
11+
namespace Magento\Framework\App\Cache\Type;
12+
13+
/**
14+
@@ -11,14 +13,29 @@ namespace Magento\Framework\App\Cache\Type;
15+
class Layout extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
16+
{
17+
/**
18+
+ * Prefix for hash kay and hash data
19+
+ */
20+
+ public const HASH_PREFIX = 'l:';
21+
+
22+
+ /**
23+
+ * Hash type, not used for security, only for uniqueness
24+
+ */
25+
+ public const HASH_TYPE = 'xxh3';
26+
+
27+
+ /**
28+
+ * Data lifetime in milliseconds
29+
+ */
30+
+ public const DATA_LIFETIME = 86_400_000; // "1 day" milliseconds
31+
+
32+
+ /**
33+
* Cache type code unique among all cache types
34+
*/
35+
- const TYPE_IDENTIFIER = 'layout';
36+
+ public const TYPE_IDENTIFIER = 'layout';
37+
38+
/**
39+
* Cache tag used to distinguish the cache type from all other cache
40+
*/
41+
- const CACHE_TAG = 'LAYOUT_GENERAL_CACHE_TAG';
42+
+ public const CACHE_TAG = 'LAYOUT_GENERAL_CACHE_TAG';
43+
44+
/**
45+
* @param FrontendPool $cacheFrontendPool
46+
@@ -27,4 +44,33 @@ class Layout extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
47+
{
48+
parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);
49+
}
50+
+
51+
+ /**
52+
+ * @inheritDoc
53+
+ */
54+
+ public function save($data, $identifier, array $tags = [], $lifeTime = null)
55+
+ {
56+
+ $dataHash = hash(self::HASH_TYPE, $data);
57+
+ $identifierForHash = self::HASH_PREFIX . $dataHash;
58+
+ return parent::save($data, $identifierForHash, $tags, self::DATA_LIFETIME) // key is hash of data hash
59+
+ && parent::save(self::HASH_PREFIX . $dataHash, $identifier, $tags, $lifeTime); // store hash of data
60+
+ }
61+
+
62+
+ /**
63+
+ * @inheritDoc
64+
+ */
65+
+ public function load($identifier)
66+
+ {
67+
+ $data = parent::load($identifier);
68+
+ if ($data === false || $data === null) {
69+
+ return $data;
70+
+ }
71+
+
72+
+ if (str_starts_with($data, self::HASH_PREFIX)) {
73+
+ // so data stored in other place
74+
+ return parent::load($data);
75+
+ } else {
76+
+ return $data;
77+
+ }
78+
+ }
79+
}
80+
diff --git a/vendor/magento/framework/Cache/Backend/Redis.php b/vendor/magento/framework/Cache/Backend/Redis.php
81+
index 565777d..9527ebc 100644
82+
--- a/vendor/magento/framework/Cache/Backend/Redis.php
83+
+++ b/vendor/magento/framework/Cache/Backend/Redis.php
84+
@@ -70,7 +70,7 @@ class Redis extends \Cm_Cache_Backend_Redis
85+
* @param bool $specificLifetime
86+
* @return bool
87+
*/
88+
- public function save($data, $id, $tags = [], $specificLifetime = false)
89+
+ public function save($data, $id, $tags = [], $specificLifetime = 86_400_000)
90+
{
91+
try {
92+
$result = parent::save($data, $id, $tags, $specificLifetime);

0 commit comments

Comments
 (0)