public function testNeverExpires() { $cache = new Cache('file_creation', $this->cacheDir); $closure = $this->createIteratorClosure(); $this->assertEquals(1, $cache->get('foo', Cache::TTL_NEVER_EXPIRES, $closure)); sleep(1); $this->assertEquals(1, $cache->get('foo', Cache::TTL_NEVER_EXPIRES, $closure)); }
/** * @return array * @throws VideoException */ public function getVendorData() { $meta = $this; return $this->cache->get($this->getVendorId(), Cache::TTL_NEVER_EXPIRES, function () use($meta) { $url = sprintf('http://youtube.com/get_video_info?video_id=%s', $meta->getVendorId()); $response = file_get_contents($url); if (!$response) { throw new VideoException(sprintf('Could not download YouTube video meta data from %s', $url)); } $data = self::unserializeData($response); if ($data === null) { throw new VideoException(sprintf('Could not parse YouTube video meta data from %s', $url)); } return $data; }); }