Skip to content

Commit 58c9025

Browse files
committed
Set the Fetch Tag Limit in config instead of hardcoded constant.
1 parent 469e34b commit 58c9025

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/Model/TagRepository.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Magento\Framework\App\ResourceConnection;
77
use IntegerNet\AsyncVarnish\Model\ResourceModel\Tag as TagResource;
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
89

910
class TagRepository
1011
{
@@ -16,7 +17,7 @@ class TagRepository
1617
/**
1718
* Limits the amount of tags being fetched from database
1819
*/
19-
const TAG_LIMIT = 1000000;
20+
const FETCH_TAG_LIMIT_CONFIG_PATH = 'system/full_page_cache/async_varnish/varnish_fetch_tag_limit';
2021

2122
private $lastUsedId;
2223

@@ -35,16 +36,25 @@ class TagRepository
3536
*/
3637
private $tagResource;
3738

39+
private $scopeConfig;
40+
3841
/**
3942
* @param \Magento\Framework\App\ResourceConnection $resource
4043
*/
4144
public function __construct(
4245
ResourceConnection $resource,
43-
TagResource $tagResource
46+
TagResource $tagResource,
47+
ScopeConfigInterface $scopeConfig
4448
) {
4549
$this->connection = $resource->getConnection();
4650
$this->resource = $resource;
4751
$this->tagResource = $tagResource;
52+
$this->scopeConfig = $scopeConfig;
53+
}
54+
55+
private function getTagFetchLimit()
56+
{
57+
return $this->scopeConfig->getValue(self::FETCH_TAG_LIMIT_CONFIG_PATH);
4858
}
4959

5060
/**
@@ -102,8 +112,9 @@ public function getAll()
102112
$tags = [];
103113

104114
$tagResource = $this->tagResource;
115+
$tagFetchLimit = $this->getTagFetchLimit();
105116

106-
$maxIdResult = $tagResource->getMaxTagId(self::TAG_LIMIT);
117+
$maxIdResult = $tagResource->getMaxTagId($tagFetchLimit);
107118

108119
if (empty($maxIdResult)) {
109120
return $tags;

src/etc/adminhtml/system.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
<field id="caching_application">1</field>
1717
</depends>
1818
</field>
19+
<field id="varnish_fetch_tag_limit" type="text" translate="label comment" sortOrder="110"
20+
showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
21+
<label>Varnish fetch tag limit.</label>
22+
<backend_model>IntegerNet\AsyncVarnish\Model\System\Config\Backend\HeaderLength</backend_model>
23+
<comment>The maximum amount of tags that are fetched in 1 purge request. This can be
24+
set to a fairly high number (1 million by default), unless you run into resource
25+
limits/timeouts.</comment>
26+
<depends>
27+
<field id="caching_application">1</field>
28+
</depends>
29+
</field>
1930
</group>
2031
</group>
2132
</section>

src/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<full_page_cache>
1111
<async_varnish>
1212
<varnish_max_header_length>8000</varnish_max_header_length>
13+
<varnish_fetch_tag_limit>1000000</varnish_fetch_tag_limit>
1314
</async_varnish>
1415
</full_page_cache>
1516
</system>

0 commit comments

Comments
 (0)