-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from magento-gl/GL_Mainline_PR_19012022_V2
Gl mainline pr 19012022 v2
- Loading branch information
Showing
4 changed files
with
134 additions
and
9 deletions.
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
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
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,51 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryIndexer\Model\GetStockItemData; | ||
|
||
class CacheStorage | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $cachedItemData = [[]]; | ||
|
||
/** | ||
* Save item to cache | ||
* | ||
* @param int $stockId | ||
* @param string $sku | ||
* @param array $stockItemData | ||
*/ | ||
public function set(int $stockId, string $sku, array $stockItemData): void | ||
{ | ||
$this->cachedItemData[$stockId][$sku] = $stockItemData; | ||
} | ||
|
||
/** | ||
* Get item from cache | ||
* | ||
* @param int $stockId | ||
* @param string $sku | ||
* @return array | ||
*/ | ||
public function get(int $stockId, string $sku): ?array | ||
{ | ||
return $this->cachedItemData[$stockId][$sku] ?? null; | ||
} | ||
|
||
/** | ||
* Delete item from cache | ||
* | ||
* @param int $stockId | ||
* @param string $sku | ||
*/ | ||
public function delete(int $stockId, string $sku): void | ||
{ | ||
unset($this->cachedItemData[$stockId][$sku]); | ||
} | ||
} |
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