Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
Change implementation to use Plugins for Cache instances
Browse files Browse the repository at this point in the history
  • Loading branch information
nuzil committed Jan 7, 2019
1 parent dd1cdec commit dad84f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
10 changes: 2 additions & 8 deletions app/code/Magento/Webapi/Model/ServiceMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ class ServiceMetadata
*/
private $serializer;

/**
* @var string
*/
private $routesConfigCacheId;

/**
* Initialize dependencies.
*
Expand All @@ -105,7 +100,6 @@ public function __construct(
$this->classReflector = $classReflector;
$this->typeProcessor = $typeProcessor;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
$this->routesConfigCacheId = self::ROUTES_CONFIG_CACHE_ID;
}

/**
Expand Down Expand Up @@ -273,7 +267,7 @@ public function getRouteMetadata($serviceName)
public function getRoutesConfig()
{
if (null === $this->routes) {
$routesConfig = $this->cache->load($this->routesConfigCacheId);
$routesConfig = $this->cache->load(self::ROUTES_CONFIG_CACHE_ID);
$typesData = $this->cache->load(self::REFLECTED_TYPES_CACHE_ID);
if ($routesConfig && is_string($routesConfig) && $typesData && is_string($typesData)) {
$this->routes = $this->serializer->unserialize($routesConfig);
Expand All @@ -282,7 +276,7 @@ public function getRoutesConfig()
$this->routes = $this->initRoutesMetadata();
$this->cache->save(
$this->serializer->serialize($this->routes),
$this->routesConfigCacheId
self::ROUTES_CONFIG_CACHE_ID
);
$this->cache->save(
$this->serializer->serialize($this->typeProcessor->getTypesData()),
Expand Down
16 changes: 0 additions & 16 deletions app/code/Magento/WebapiAsync/Plugin/ServiceMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

class ServiceMetadata
{

const ASYNC_ROUTES_CONFIG_CACHE_ID = 'async-routes-services-config';

/**
* @var \Magento\Webapi\Model\Config
*/
Expand Down Expand Up @@ -275,17 +272,4 @@ 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;
}
}

0 comments on commit dad84f4

Please sign in to comment.