diff --git a/app/code/Magento/Webapi/Model/ServiceMetadata.php b/app/code/Magento/Webapi/Model/ServiceMetadata.php index b56aa84b946..54b8557214c 100644 --- a/app/code/Magento/Webapi/Model/ServiceMetadata.php +++ b/app/code/Magento/Webapi/Model/ServiceMetadata.php @@ -79,6 +79,11 @@ class ServiceMetadata */ private $serializer; + /** + * @var string + */ + private $routesConfigCacheId; + /** * Initialize dependencies. * @@ -100,6 +105,7 @@ public function __construct( $this->classReflector = $classReflector; $this->typeProcessor = $typeProcessor; $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class); + $this->routesConfigCacheId = self::ROUTES_CONFIG_CACHE_ID; } /** @@ -267,7 +273,7 @@ public function getRouteMetadata($serviceName) public function getRoutesConfig() { if (null === $this->routes) { - $routesConfig = $this->cache->load(self::ROUTES_CONFIG_CACHE_ID); + $routesConfig = $this->cache->load($this->routesConfigCacheId); $typesData = $this->cache->load(self::REFLECTED_TYPES_CACHE_ID); if ($routesConfig && is_string($routesConfig) && $typesData && is_string($typesData)) { $this->routes = $this->serializer->unserialize($routesConfig); @@ -276,7 +282,7 @@ public function getRoutesConfig() $this->routes = $this->initRoutesMetadata(); $this->cache->save( $this->serializer->serialize($this->routes), - self::ROUTES_CONFIG_CACHE_ID + $this->routesConfigCacheId ); $this->cache->save( $this->serializer->serialize($this->typeProcessor->getTypesData()), @@ -287,6 +293,17 @@ public function getRoutesConfig() return $this->routes; } + /** + * Set Routes Config Cache ID + * + * @param string $routesConfigCacheId + */ + public function setRoutesConfigCacheId($routesConfigCacheId){ + + $this->routesConfigCacheId = $routesConfigCacheId; + + } + /** * Collect the list of services with routes and request types for use in REST. * diff --git a/app/code/Magento/WebapiAsync/Plugin/ServiceMetadata.php b/app/code/Magento/WebapiAsync/Plugin/ServiceMetadata.php index c4e5b572b80..fdd320e4a57 100644 --- a/app/code/Magento/WebapiAsync/Plugin/ServiceMetadata.php +++ b/app/code/Magento/WebapiAsync/Plugin/ServiceMetadata.php @@ -15,6 +15,9 @@ class ServiceMetadata { + + const ASYNC_ROUTES_CONFIG_CACHE_ID = 'async-routes-services-config'; + /** * @var \Magento\Webapi\Model\Config */ @@ -272,4 +275,17 @@ private function getResponseDefinitionReplacement() return $this->responseDefinitionReplacement; } + + /** + * Plugin to change config cache id for Asynchronous operations + * + * @return null + */ + public function beforeGetRoutesConfig(\Magento\Webapi\Model\ServiceMetadata $subject) + { + if ($this->asynchronousSchemaRequestProcessor->canProcess($this->request)) { + $subject->setRoutesConfigCacheId(self::ASYNC_ROUTES_CONFIG_CACHE_ID); + } + return null; + } }