Open Journal Systems  3.3.0
DefaultCacheKeyProvider.php
1 <?php
2 
3 namespace Guzzle\Plugin\Cache;
4 
6 
7 \Guzzle\Common\Version::warn('Guzzle\Plugin\Cache\DefaultCacheKeyProvider is no longer used');
8 
14 {
15  public function getCacheKey(RequestInterface $request)
16  {
17  // See if the key has already been calculated
18  $key = $request->getParams()->get(self::CACHE_KEY);
19 
20  if (!$key) {
21 
22  $cloned = clone $request;
23  $cloned->removeHeader('Cache-Control');
24 
25  // Check to see how and if the key should be filtered
26  foreach (explode(';', $request->getParams()->get(self::CACHE_KEY_FILTER)) as $part) {
27  $pieces = array_map('trim', explode('=', $part));
28  if (isset($pieces[1])) {
29  foreach (array_map('trim', explode(',', $pieces[1])) as $remove) {
30  if ($pieces[0] == 'header') {
31  $cloned->removeHeader($remove);
32  } elseif ($pieces[0] == 'query') {
33  $cloned->getQuery()->remove($remove);
34  }
35  }
36  }
37  }
38 
39  $raw = (string) $cloned;
40  $key = 'GZ' . md5($raw);
41  $request->getParams()->set(self::CACHE_KEY, $key)->set(self::CACHE_KEY_RAW, $raw);
42  }
43 
44  return $key;
45  }
46 }
Guzzle\Http\Message\RequestInterface
Definition: lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/RequestInterface.php:16
Guzzle\Plugin\Cache
Definition: CacheKeyProviderInterface.php:3
Guzzle\Http\Message\MessageInterface\removeHeader
removeHeader($header)
Guzzle\Common\Version\warn
static warn($message)
Definition: Version.php:23
Guzzle\Plugin\Cache\DefaultCacheKeyProvider\getCacheKey
getCacheKey(RequestInterface $request)
Definition: DefaultCacheKeyProvider.php:15
Guzzle\Plugin\Cache\DefaultCacheKeyProvider
Definition: DefaultCacheKeyProvider.php:13
Guzzle\Http\Message\MessageInterface\getParams
getParams()
Guzzle\Plugin\Cache\CacheKeyProviderInterface
Definition: CacheKeyProviderInterface.php:11