Skip to content

Commit 206d9af

Browse files
committed
ACPT-867: STRUCTURE LAYOUT cache generates for each product category and takes ~18Kb (GZIP) per ea.
- fix some problem find by tests
1 parent 61bab7b commit 206d9af

File tree

1 file changed

+10
-7
lines changed
  • lib/internal/Magento/Framework/App/Cache/Type

1 file changed

+10
-7
lines changed

lib/internal/Magento/Framework/App/Cache/Type/Layout.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ class Layout extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
1616
private const HASH_PREFIX = 'l:';
1717

1818
/**
19-
* Hash type
19+
* Hash type, not used for security, only for uniqueness
2020
*/
2121
private const HASH_TYPE = 'xxh3';
2222

23-
private const DATA_LIFETIME = 86_400_000; // "1 day" miliseconds
23+
/**
24+
* Data lifetime in milliseconds
25+
*/
26+
private const DATA_LIFETIME = 86_400_000; // "1 day" milliseconds
27+
2428
/**
2529
* Cache type code unique among all cache types
2630
*/
27-
const TYPE_IDENTIFIER = 'layout';
31+
public const TYPE_IDENTIFIER = 'layout';
2832

2933
/**
3034
* Cache tag used to distinguish the cache type from all other cache
3135
*/
32-
const CACHE_TAG = 'LAYOUT_GENERAL_CACHE_TAG';
36+
public const CACHE_TAG = 'LAYOUT_GENERAL_CACHE_TAG';
3337

3438
/**
3539
* @param FrontendPool $cacheFrontendPool
@@ -47,8 +51,7 @@ public function save($data, $identifier, array $tags = [], $lifeTime = null)
4751
$dataHash = hash(self::HASH_TYPE, $data);
4852
$identifierForHash = self::HASH_PREFIX . $dataHash;
4953
return parent::save($data, $identifierForHash, $tags, self::DATA_LIFETIME) // key is hash of data hash
50-
&& parent::save(self::HASH_PREFIX . $dataHash, $identifier, $tags, $lifeTime); // store hash of data
51-
54+
&& parent::save(self::HASH_PREFIX . $dataHash, $identifier, $tags, $lifeTime); // store hash of data
5255
}
5356

5457
/**
@@ -57,7 +60,7 @@ public function save($data, $identifier, array $tags = [], $lifeTime = null)
5760
public function load($identifier)
5861
{
5962
$data = parent::load($identifier);
60-
if ($data === false) {
63+
if ($data === false || $data === null) {
6164
return $data;
6265
}
6366

0 commit comments

Comments
 (0)