Skip to content

Commit ab0e5cb

Browse files
authored
Merge pull request #38 from Zheness/update_cache_key
Update the cache key by including namespace
2 parents 6af5c28 + dd268a8 commit ab0e5cb

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Mappers/GlobTypeMapper.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,14 @@ private function storeTypeInCache(string $typeClassName, Type $type, string $typ
385385
{
386386
$objectClassName = $type->getClass();
387387
$this->mapClassToTypeArray[$objectClassName] = $typeClassName;
388-
$this->cache->set('globTypeMapperByClass_'.str_replace('\\', '_', $objectClassName), [
388+
$this->cache->set('globTypeMapperByClass_'.str_replace('\\', '_', $this->namespace).'_'.str_replace('\\', '_', $objectClassName), [
389389
'filemtime' => filemtime($typeFileName),
390390
'fileName' => $typeFileName,
391391
'typeClass' => $typeClassName
392392
], $this->mapTtl);
393393
$typeName = $this->namingStrategy->getOutputTypeName($typeClassName, $type);
394394
$this->mapNameToType[$typeName] = $typeClassName;
395-
$this->cache->set('globTypeMapperByName_'.$typeName, [
395+
$this->cache->set('globTypeMapperByName_'.str_replace('\\', '_', $this->namespace).'_'.$typeName, [
396396
'filemtime' => filemtime($typeFileName),
397397
'fileName' => $typeFileName,
398398
'typeClass' => $typeClassName
@@ -406,13 +406,13 @@ private function storeInputTypeInCache(ReflectionMethod $refMethod, string $inpu
406406
{
407407
$refArray = [$refMethod->getDeclaringClass()->getName(), $refMethod->getName()];
408408
$this->mapClassToFactory[$className] = $refArray;
409-
$this->cache->set('globInputTypeMapperByClass_'.str_replace('\\', '_', $className), [
409+
$this->cache->set('globInputTypeMapperByClass_'.str_replace('\\', '_', $this->namespace).'_'.str_replace('\\', '_', $className), [
410410
'filemtime' => filemtime($fileName),
411411
'fileName' => $fileName,
412412
'factory' => $refArray
413413
], $this->mapTtl);
414414
$this->mapInputNameToFactory[$inputName] = $refArray;
415-
$this->cache->set('globInputTypeMapperByName_'.$inputName, [
415+
$this->cache->set('globInputTypeMapperByName_'.str_replace('\\', '_', $this->namespace).'_'.$inputName, [
416416
'filemtime' => filemtime($fileName),
417417
'fileName' => $fileName,
418418
'factory' => $refArray
@@ -427,7 +427,7 @@ private function storeExtendTypeMapperByClassInCache(string $extendTypeClassName
427427
{
428428
$objectClassName = $extendType->getClass();
429429
$this->mapClassToExtendTypeArray[$objectClassName][$extendTypeClassName] = $extendTypeClassName;
430-
$this->cache->set('globExtendTypeMapperByClass_'.str_replace('\\', '_', $objectClassName), [
430+
$this->cache->set('globExtendTypeMapperByClass_'.str_replace('\\', '_', $this->namespace).'_'.str_replace('\\', '_', $objectClassName), [
431431
'filemtime' => filemtime($typeFileName),
432432
'fileName' => $typeFileName,
433433
'extendTypeClasses' => $this->mapClassToExtendTypeArray[$objectClassName]
@@ -443,7 +443,7 @@ private function storeExtendTypeMapperByNameInCache(string $extendTypeClassName,
443443
$typeName = $targetType->name;
444444

445445
$this->mapNameToExtendType[$typeName][$extendTypeClassName] = $extendTypeClassName;
446-
$this->cache->set('globExtendTypeMapperByName_'.$typeName, [
446+
$this->cache->set('globExtendTypeMapperByName_'.str_replace('\\', '_', $this->namespace).'_'.$typeName, [
447447
'filemtime' => filemtime($typeFileName),
448448
'fileName' => $typeFileName,
449449
'extendTypeClasses' => $this->mapNameToExtendType[$typeName]
@@ -457,7 +457,7 @@ private function getTypeFromCacheByObjectClass(string $className): ?string
457457
}
458458

459459
// Let's try from the cache
460-
$item = $this->cache->get('globTypeMapperByClass_'.str_replace('\\', '_', $className));
460+
$item = $this->cache->get('globTypeMapperByClass_'.str_replace('\\', '_', $this->namespace).'_'.str_replace('\\', '_', $className));
461461
if ($item !== null) {
462462
[
463463
'filemtime' => $filemtime,
@@ -482,7 +482,7 @@ private function getTypeFromCacheByGraphQLTypeName(string $graphqlTypeName): ?st
482482
}
483483

484484
// Let's try from the cache
485-
$item = $this->cache->get('globTypeMapperByName_'.$graphqlTypeName);
485+
$item = $this->cache->get('globTypeMapperByName_'.str_replace('\\', '_', $this->namespace).'_'.$graphqlTypeName);
486486
if ($item !== null) {
487487
[
488488
'filemtime' => $filemtime,
@@ -510,7 +510,7 @@ private function getFactoryFromCacheByObjectClass(string $className): ?array
510510
}
511511

512512
// Let's try from the cache
513-
$item = $this->cache->get('globInputTypeMapperByClass_'.str_replace('\\', '_', $className));
513+
$item = $this->cache->get('globInputTypeMapperByClass_'.str_replace('\\', '_', $this->namespace).'_'.str_replace('\\', '_', $className));
514514
if ($item !== null) {
515515
[
516516
'filemtime' => $filemtime,
@@ -539,7 +539,7 @@ private function getExtendTypesFromCacheByObjectClass(string $className): ?array
539539
}
540540

541541
// Let's try from the cache
542-
$item = $this->cache->get('globExtendTypeMapperByClass_'.str_replace('\\', '_', $className));
542+
$item = $this->cache->get('globExtendTypeMapperByClass_'.str_replace('\\', '_', $this->namespace).'_'.str_replace('\\', '_', $className));
543543
if ($item !== null) {
544544
[
545545
'filemtime' => $filemtime,
@@ -568,7 +568,7 @@ private function getExtendTypesFromCacheByGraphQLTypeName(string $graphqlTypeNam
568568
}
569569

570570
// Let's try from the cache
571-
$item = $this->cache->get('globExtendTypeMapperByName_'.$graphqlTypeName);
571+
$item = $this->cache->get('globExtendTypeMapperByName_'.str_replace('\\', '_', $this->namespace).'_'.$graphqlTypeName);
572572
if ($item !== null) {
573573
[
574574
'filemtime' => $filemtime,
@@ -596,7 +596,7 @@ private function getFactoryFromCacheByGraphQLInputTypeName(string $graphqlTypeNa
596596
}
597597

598598
// Let's try from the cache
599-
$item = $this->cache->get('globInputTypeMapperByName_'.$graphqlTypeName);
599+
$item = $this->cache->get('globInputTypeMapperByName_'.str_replace('\\', '_', $this->namespace).'_'.$graphqlTypeName);
600600
if ($item !== null) {
601601
[
602602
'filemtime' => $filemtime,

src/Types/TypeAnnotatedObjectType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function createFromAnnotatedClass(string $typeName, string $classN
4343
$fields = $fieldProvider->getSelfFields($className);
4444
}
4545
if ($parentType !== null) {
46-
$fields = $parentType->getFields() + $fields;
46+
$fields += $parentType->getFields();
4747
}
4848
return $fields;
4949
},

0 commit comments

Comments
 (0)