You are here

protected function DataProducerProxy::edgeCachePrefix in GraphQL 8.4

Calculates a cache prefix.

Parameters

\Drupal\graphql\Plugin\DataProducerPluginCachingInterface $plugin:

Return value

string

1 call to DataProducerProxy::edgeCachePrefix()
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 274

Class

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

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer

Code

protected function edgeCachePrefix(DataProducerPluginCachingInterface $plugin) {
  try {
    $prefix = $plugin
      ->edgeCachePrefix();
  } catch (\Exception $e) {
    throw new \LogicException(sprintf('Failed to serialize edge cache vectors for plugin %s.', $plugin
      ->getPluginId()));
  }
  $contexts = $plugin
    ->getCacheContexts();
  $keys = $this->contextsManager
    ->convertTokensToKeys($contexts)
    ->getKeys();
  return md5(serialize([
    $plugin
      ->getPluginId(),
    $prefix,
    $keys,
  ]));
}