protected function Executor::cacheWrite in GraphQL 8.4
Store results in cache.
Parameters
string $prefix:
\Drupal\graphql\GraphQL\Execution\ExecutionResult $result:
Return value
\Drupal\graphql\GraphQL\Execution\Executor
1 call to Executor::cacheWrite()
- Executor::doExecuteCached in src/
GraphQL/ Execution/ Executor.php - Try to return cached results, otherwise resolve the query.
File
- src/
GraphQL/ Execution/ Executor.php, line 351
Class
- Executor
- Executes GraphQL queries with cache lookup.
Namespace
Drupal\graphql\GraphQL\ExecutionCode
protected function cacheWrite($prefix, CacheableExecutionResult $result) {
$contexts = $result
->getCacheContexts();
$expire = $this
->maxAgeToExpire($result
->getCacheMaxAge());
$tags = $result
->getCacheTags();
$suffix = $this
->cacheSuffix($contexts);
$metadata = new CacheableMetadata();
$metadata
->addCacheableDependency($result);
$cache = [
'data' => $result->data,
'extensions' => $result->extensions,
'metadata' => $metadata,
];
$this->cacheBackend
->setMultiple([
"contexts:{$prefix}" => [
'data' => $contexts,
'expire' => $expire,
'tags' => $tags,
],
"result:{$prefix}:{$suffix}" => [
'data' => $cache,
'expire' => $expire,
'tags' => $tags,
],
]);
return $this;
}