- last update
over 1 year ago Patch Failed to Apply
When we use external entities in search api,we found external entities cache will not clear when we rebuild tracker information.
We need manually clear that cache,that would be not intelligent.
1.Create one external entities type.
2.Use search api to create a index which data source from external entites.
3.Create a view make it list data from search api index,and set cache tag as " Search API (tag-based)".
4.After we rebuild tracker for search api,we found data not changed
We can add a field for external entities named persistent_cache_tags,then update form make it can be added multiply,In external entities storage and entity type class, use getCacheTags and getCacheTagsToInvalidate function to realize it.
I found the cache tags logic like this:
<?php
protected function setPersistentCache($entities) {
if (!$this->entityType->isPersistentlyCacheable()) {
return;
}
$cache_tags = [
$this->entityTypeId . '_values',
'entity_field_info',
];
foreach ($entities as $id => $entity) {
$max_age = $this->getExternalEntityType()->getPersistentCacheMaxAge();
$expire = $max_age === Cache::PERMANENT
? Cache::PERMANENT
: $this->time->getRequestTime() + $max_age;
$this->cacheBackend->set($this->buildCacheId($id), $entity, $expire, $cache_tags);
}
}
?>
So this logic get cache tags need update,otherwise our custom cache tag can't merged into it.
Needs review
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.