You are here

protected function DataProducerProxy::cacheRead in GraphQL 8.4

Cache lookup.

Parameters

string $prefix:

Return value

array|null

1 call to DataProducerProxy::cacheRead()
DataProducerProxy::resolveCached in src/Plugin/GraphQL/DataProducer/DataProducerProxy.php
Try to return a value from cache, otherwise invoke data producer.

File

src/Plugin/GraphQL/DataProducer/DataProducerProxy.php, line 294

Class

DataProducerProxy
A proxy class that lazy resolves data producers and has a result cache.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer

Code

protected function cacheRead($prefix) {
  if ($cache = $this->cacheBackend
    ->get("{$prefix}:context")) {
    $keys = !empty($cache->data) ? $this->contextsManager
      ->convertTokensToKeys($cache->data)
      ->getKeys() : [];
    $keys = serialize($keys);
    if (($cache = $this->cacheBackend
      ->get("{$prefix}:result:{$keys}")) && ($data = $cache->data)) {
      return $data;
    }
  }
  return NULL;
}