-
Notifications
You must be signed in to change notification settings - Fork 90
Port cache invalidation to 2.x #369
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix the issue in our end, looks good to. me
@@ -53,11 +62,13 @@ public function execute(array $ids) | |||
foreach ($stores as $store) { | |||
$this->getIndexerHandler()->saveIndex($this->rebuild((int) $store->getId(), []), $store); | |||
$this->getIndexerHandler()->cleanUpByTransactionKey($store); | |||
$this->cacheProcessor->cleanCacheByTags($store->getId(), [$this->getIndexerHandler()->getTypeName()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you need add checking for
$cacheTags = $this-> cacheProcessor->getCacheTags();
isset($cacheTags[$this->getIndexerHandler()];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarron93 I added validation on cacheProcessor side https://github.com/vuestorefront/magento2-vsbridge-indexer/pull/369/files#diff-cacba1bef0b62da01a4252e13e6ad3da6560b711431bf6ed774cf085423fd541 please have a look
} | ||
} else { | ||
foreach ($stores as $store) { | ||
$this->getIndexerHandler()->createIndex($store); | ||
$this->getIndexerHandler()->saveIndex($this->rebuild((int) $store->getId(), []), $store); | ||
$this->cacheProcessor->cleanCacheByTags($store->getId(), [$this->getIndexerHandler()->getTypeName()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you need add checking for
$cacheTags = $this-> cacheProcessor->getCacheTags();
isset($cacheTags[$this->getTypeName()];
and set to second params $cacheTags[$this->getIndexerHandler()->getTypeName()]
because cleanCacheByTags method don't check cache tag value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarron93 I added validation on cacheProcessor side https://github.com/vuestorefront/magento2-vsbridge-indexer/pull/369/files#diff-cacba1bef0b62da01a4252e13e6ad3da6560b711431bf6ed774cf085423fd541 please have a look
@@ -22,6 +52,7 @@ public function execute(array $ids) | |||
foreach ($stores as $store) { | |||
$this->getIndexerHandler()->saveIndex($this->rebuild((int) $store->getId(), $ids), $store); | |||
$this->getIndexerHandler()->cleanUpByTransactionKey($store, $ids); | |||
$this->cacheProcessor->cleanCacheByDocIds($store->getId(), $this->getIndexerHandler()->getTypeName(), $ids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$cacheTags = $this->cacheProcessor->getCacheTags();
if (isset($cacheTags[$this->getIndexerHandler()->getTypeName()])) {
$this->cacheProcessor->cleanCacheByDocIds(
$store->getId(),
$this->getIndexerHandler()->getTypeName(),
$ids
);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarron93 I added validation on cacheProcessor side https://github.com/vuestorefront/magento2-vsbridge-indexer/pull/369/files#diff-cacba1bef0b62da01a4252e13e6ad3da6560b711431bf6ed774cf085423fd541 please have a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little data validation and will be a 🚀
Hi, any progress with getting this merged? :) |
Hi @tunght13488, I tried your latest changes and they are working a lot better. However there is still one issue I found, when adding a new product in magento I cannot see it when viewing the categories in vue storefront. I need to update an old product before it is displayed. Entering the url to the new product works though. |
This PR only tries to port the existing cache invalidation logic into 2.x, not fixing anything For your case I suggest looking into index table. Adding new product should add some changelog to vsbridge product index |
@@ -1,3 +1,4 @@ | |||
.idea | |||
composer.phar | |||
/vendor/ | |||
composer.lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this shouldn't be ignored
use Magento\Framework\Event\ManagerInterface as EventManager; | ||
use Magento\Framework\HTTP\Adapter\CurlFactory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong order. Imports should be alphabetical
if ($this->config->clearCache($storeId)) { | ||
$cacheTags = implode(',', $tags); | ||
$cacheInvalidateUrl = $this->getInvalidateCacheUrl($storeId) . $cacheTags; | ||
$cacheTags = array_intersect($tags, $this->getCacheTags()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be:
$cacheTags = array_intersect_key($this->getCacheTags(), array_flip($tags));
No description provided.