예제 #1
0
 /**
  * 
  * @param FileVault $vault
  * @param string $url
  * @param integer $retention
  * @return ResponseFile
  */
 protected function getVaultResponseFile(FileVault $vault, $url, $retention)
 {
     if ($vault->exists($url)) {
         $filepath = $vault->getVaultFilename($url);
         if (time() - filemtime($filepath) < 86400 * $retention) {
             return $vault->getResponse($url);
         }
     }
     $curl = new Curl();
     $curl->setUrl($url);
     $curl->setTimeout(10);
     $response = $curl->execute();
     if ($response->getInfoHttpCode() == 200) {
         $content = $response->getContent();
         $vault->set($url, $content);
         return $vault->getResponse($url);
     }
     return null;
 }
예제 #2
0
 public function getResponse($url)
 {
     if (empty($url)) {
         return null;
     }
     if ($this->exists($url)) {
         $filepath = $this->getVaultFilename($url);
         if (time() - filemtime($filepath) < 86400 * 15) {
             return parent::getResponse($url);
         }
     }
     $curl = new Curl();
     $curl->setUrl($url);
     $curl->setTimeout(10);
     $response = $curl->execute();
     if ($response->getInfoHttpCode() == 200) {
         $content = $response->getContent();
         $this->set($url, $content);
         return parent::getResponse($url);
     }
     return null;
 }