Skip to content

Commit 2fbf8ca

Browse files
authored
IBX-9103: Fixed cache tag name not including relation type (#437)
For more details see https://issues.ibexa.co/browse/IBX-9103 and #437 Key changes: * IBX-9103: Fixed cache tag name not including relation type
1 parent c338dc5 commit 2fbf8ca

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/lib/Persistence/Cache/ContentHandler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -620,18 +620,18 @@ public function countReverseRelations(int $destinationContentId, ?int $type = nu
620620
$cacheItem = $this->cache->getItem(
621621
$this->cacheIdentifierGenerator->generateKey(
622622
self::CONTENT_REVERSE_RELATIONS_COUNT_IDENTIFIER,
623-
[$destinationContentId],
623+
[$destinationContentId, $type],
624624
true
625625
)
626626
);
627627

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

631631
return $cacheItem->get();
632632
}
633633

634-
$this->logger->logCacheMiss(['content' => $destinationContentId]);
634+
$this->logger->logCacheMiss(['content' => $destinationContentId, 'type' => $type]);
635635
$reverseRelationsCount = $this->persistenceHandler->contentHandler()->countReverseRelations($destinationContentId, $type);
636636
$cacheItem->set($reverseRelationsCount);
637637
$tags = [

src/lib/Resources/settings/storage_engines/cache.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ parameters:
121121
content_locations: 'cl-%s'
122122
content_relations_count_with_by_version_type_suffix: 'crc-%%s-v-%%s-t-%%s'
123123
content_relations_list_with_by_version_type_suffix: 'crl-%%s-l-%%s-o-%%s-v-%%s-t-%%s'
124-
content_reverse_relations_count: 'crrc-%s'
124+
content_reverse_relations_count: 'crrc-%%s-t-%%s'
125125
content_version_info: 'cvi-%s'
126126
content_version_list: 'c-%s-vl'
127127
content_version: 'c-%%s-v-%%s'

tests/lib/Persistence/Cache/ContentHandlerTest.php

+19-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public function providerForCachedLoadMethodsHit(): array
9393

9494
// string $method, array $arguments, string $key, array? $tagGeneratingArguments, array? $tagGeneratingResults, array? $keyGeneratingArguments, array? $keyGeneratingResults, mixed? $data, bool $multi = false, array $additionalCalls
9595
return [
96-
['countReverseRelations', [2], 'ibx-crrc-2', null, null, [['content_reverse_relations_count', [2], true]], ['ibx-crrc-2'], 10],
96+
['countReverseRelations', [2, null], 'ibx-crrc-2-t-', null, null, [['content_reverse_relations_count', [2, null], true]], ['ibx-crrc-2-t-'], 10],
97+
['countReverseRelations', [2, 8], 'ibx-crrc-2-t-8', null, null, [['content_reverse_relations_count', [2, 8], true]], ['ibx-crrc-2-t-8'], 10],
9798
['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],
9899
['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],
99100
['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],
@@ -136,15 +137,29 @@ public function providerForCachedLoadMethodsMiss(): array
136137
[
137138
'countReverseRelations',
138139
[2],
139-
'ibx-crrc-2',
140+
'ibx-crrc-2-t-',
140141
[
141142
['content', [2], false],
142143
],
143144
['c-2'],
144145
[
145-
['content_reverse_relations_count', [2], true],
146+
['content_reverse_relations_count', [2, null], true],
146147
],
147-
['ibx-crrc-2'],
148+
['ibx-crrc-2-t-'],
149+
10,
150+
],
151+
[
152+
'countReverseRelations',
153+
[2, 8],
154+
'ibx-crrc-2-t-8',
155+
[
156+
['content', [2], false],
157+
],
158+
['c-2'],
159+
[
160+
['content_reverse_relations_count', [2, 8], true],
161+
],
162+
['ibx-crrc-2-t-8'],
148163
10,
149164
],
150165
[

0 commit comments

Comments
 (0)