Пример #1
0
 public function testGetWithCache()
 {
     $cacheFactory = new CacheFactory();
     $cache = $cacheFactory->get('file', array('directory' => '/tmp/adapter-test-get-with-cache'));
     $adapter = $this->getAdapter();
     $adapter->setCache($cache);
     $firstResult = $adapter->get('widgets');
     $cachedResult = $adapter->get('widgets');
     $this->assertNull($adapter->getRequest());
     $this->assertEquals($firstResult, $cachedResult);
 }
Пример #2
0
 /**
  * @inheritDoc
  */
 public function getAdapter()
 {
     if (!$this->adapter) {
         $this->adapter = new Adapter\GuzzleAdapter();
         $this->adapter->setBaseUrl($this->getBaseUrl());
         $options = $this->options;
         if (isset($options['cache'])) {
             $cacheOptions = $options['cache'];
             unset($options['cache']);
         }
         $this->adapter->setOptions($this->options);
         if (!empty($cacheOptions)) {
             $cacheProvider = $cacheOptions['provider'];
             unset($cacheOptions['provider']);
             $cacheFactory = new CacheFactory();
             $cache = $cacheFactory->get($cacheProvider, $cacheOptions);
             $this->adapter->setCache($cache);
         }
     }
     return $this->adapter;
 }