Beispiel #1
0
 protected function getContents($url, $headers = [], $as_html = false)
 {
     $key = $this->buildCacheKey($url);
     if (self::$cache->has($key)) {
         return self::$cache->get($key);
     }
     if ($as_html) {
         foreach ($headers as $k => $v) {
             $this->client->setHeader($k, $v);
         }
         $contents = $this->client->request('GET', $url)->html();
         foreach ($headers as $k => $v) {
             $this->client->removeHeader($k);
         }
     } else {
         $contents = file_get_contents($url);
     }
     self::$cache->set($key, $contents);
     return $contents;
 }
Beispiel #2
0
 public function __construct(\Memcache $memcache, $default_ttl)
 {
     parent::__construct($default_ttl);
     $this->instance = $memcache;
 }
Beispiel #3
0
 public function __construct($path, $ttl)
 {
     parent::__construct($ttl);
     $this->path = $path;
 }