-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LYNX-149: Cache identity for attributesMetadata query (#114)
* LYNX-149: Cache identity for attributesMetadata query
- Loading branch information
1 parent
29519af
commit 6c4024f
Showing
4 changed files
with
423 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/code/Magento/EavGraphQl/Model/Resolver/Cache/CustomAttributeMetadataV2Identity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\EavGraphQl\Model\Resolver\Cache; | ||
|
||
use Magento\Eav\Model\Entity\Attribute as EavAttribute; | ||
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface; | ||
|
||
/** | ||
* Cache identity provider for custom attribute metadata query results. | ||
*/ | ||
class CustomAttributeMetadataV2Identity implements IdentityInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getIdentities(array $resolvedData): array | ||
{ | ||
$identities = []; | ||
if (isset($resolvedData['items']) && !empty($resolvedData['items'])) { | ||
foreach ($resolvedData['items'] as $item) { | ||
if (is_array($item)) { | ||
$identities[] = sprintf( | ||
"%s_%s", | ||
EavAttribute::CACHE_TAG, | ||
$item['id'] | ||
); | ||
} | ||
} | ||
} else { | ||
return []; | ||
} | ||
return $identities; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.