Open Journal Systems  3.3.0
CachingConfigLoader.php
1 <?php
2 
3 namespace Guzzle\Service;
4 
6 
11 {
13  protected $loader;
14 
16  protected $cache;
17 
23  {
24  $this->loader = $loader;
25  $this->cache = $cache;
26  }
27 
28  public function load($config, array $options = array())
29  {
30  if (!is_string($config)) {
31  $key = false;
32  } else {
33  $key = 'loader_' . crc32($config);
34  if ($result = $this->cache->fetch($key)) {
35  return $result;
36  }
37  }
38 
39  $result = $this->loader->load($config, $options);
40  if ($key) {
41  $this->cache->save($key, $result);
42  }
43 
44  return $result;
45  }
46 }
Guzzle\Cache\CacheAdapterInterface
Definition: CacheAdapterInterface.php:12
Guzzle\Service\CachingConfigLoader\$loader
$loader
Definition: CachingConfigLoader.php:16
Guzzle\Service\CachingConfigLoader
Definition: CachingConfigLoader.php:10
Guzzle\Service\ConfigLoaderInterface
Definition: ConfigLoaderInterface.php:11
Guzzle\Service
Definition: AbstractConfigLoader.php:3
Guzzle\Service\CachingConfigLoader\load
load($config, array $options=array())
Definition: CachingConfigLoader.php:34
Guzzle\Service\CachingConfigLoader\$cache
$cache
Definition: CachingConfigLoader.php:22
Guzzle\Service\CachingConfigLoader\__construct
__construct(ConfigLoaderInterface $loader, CacheAdapterInterface $cache)
Definition: CachingConfigLoader.php:28