Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-9103: Fixed cache tag name not including relation type #437

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/Persistence/Cache/ContentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,18 +620,18 @@ public function countReverseRelations(int $destinationContentId, ?int $type = nu
$cacheItem = $this->cache->getItem(
$this->cacheIdentifierGenerator->generateKey(
self::CONTENT_REVERSE_RELATIONS_COUNT_IDENTIFIER,
[$destinationContentId],
[$destinationContentId, $type],
true
)
);

if ($cacheItem->isHit()) {
$this->logger->logCacheHit(['content' => $destinationContentId]);
$this->logger->logCacheHit(['content' => $destinationContentId, 'type' => $type]);

return $cacheItem->get();
}

$this->logger->logCacheMiss(['content' => $destinationContentId]);
$this->logger->logCacheMiss(['content' => $destinationContentId, 'type' => $type]);
$reverseRelationsCount = $this->persistenceHandler->contentHandler()->countReverseRelations($destinationContentId, $type);
$cacheItem->set($reverseRelationsCount);
$tags = [
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Resources/settings/storage_engines/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ parameters:
content_locations: 'cl-%s'
content_relations_count_with_by_version_type_suffix: 'crc-%%s-v-%%s-t-%%s'
content_relations_list_with_by_version_type_suffix: 'crl-%%s-l-%%s-o-%%s-v-%%s-t-%%s'
content_reverse_relations_count: 'crrc-%s'
content_reverse_relations_count: 'crrc-%%s-t-%%s'
content_version_info: 'cvi-%s'
content_version_list: 'c-%s-vl'
content_version: 'c-%%s-v-%%s'
Expand Down
23 changes: 19 additions & 4 deletions tests/lib/Persistence/Cache/ContentHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function providerForCachedLoadMethodsHit(): array

// string $method, array $arguments, string $key, array? $tagGeneratingArguments, array? $tagGeneratingResults, array? $keyGeneratingArguments, array? $keyGeneratingResults, mixed? $data, bool $multi = false, array $additionalCalls
return [
['countReverseRelations', [2], 'ibx-crrc-2', null, null, [['content_reverse_relations_count', [2], true]], ['ibx-crrc-2'], 10],
['countReverseRelations', [2, null], 'ibx-crrc-2-t-', null, null, [['content_reverse_relations_count', [2, null], true]], ['ibx-crrc-2-t-'], 10],
['countReverseRelations', [2, 8], 'ibx-crrc-2-t-8', null, null, [['content_reverse_relations_count', [2, 8], true]], ['ibx-crrc-2-t-8'], 10],
['countRelations', [2], 'ibx-crc-2-v--t-', null, null, [['content_relations_count_with_by_version_type_suffix', [2, null, null], true]], ['ibx-crc-2-v--t-'], 10],
['countRelations', [2, 2], 'ibx-crc-2-v-2-t-', null, null, [['content_relations_count_with_by_version_type_suffix', [2, 2, null], true]], ['ibx-crc-2-v-2-t-'], 10],
['countRelations', [2, null, 1], 'ibx-crc-2-v--t-1', null, null, [['content_relations_count_with_by_version_type_suffix', [2, null, 1], true]], ['ibx-crc-2-v--t-1'], 10],
Expand Down Expand Up @@ -136,15 +137,29 @@ public function providerForCachedLoadMethodsMiss(): array
[
'countReverseRelations',
[2],
'ibx-crrc-2',
'ibx-crrc-2-t-',
[
['content', [2], false],
],
['c-2'],
[
['content_reverse_relations_count', [2], true],
['content_reverse_relations_count', [2, null], true],
],
['ibx-crrc-2'],
['ibx-crrc-2-t-'],
10,
],
[
'countReverseRelations',
[2, 8],
'ibx-crrc-2-t-8',
[
['content', [2], false],
],
['c-2'],
[
['content_reverse_relations_count', [2, 8], true],
],
['ibx-crrc-2-t-8'],
10,
],
[
Expand Down
Loading