public function setByReference($scope_id, $reference, $type = null)
 {
     $contents = CacheUtils::fetch($reference);
     if (!$contents) {
         return false;
     } else {
         if ($type != null && !array_key_exists($contents['content_type'], $type)) {
             return false;
         }
         return $this->memcache->set($this->makeKey($scope_id, $key), $contents, MEMCACHE_COMPRESSED, $this->expires);
     }
 }
Example #2
0
 public function setByReference($scope_id, $reference, $type = null)
 {
     // TODO make sure valid content
     try {
         $contents = CacheUtils::fetch($reference);
         if ($contents === false) {
             return false;
         } else {
             if ($contents['http_code'] != '200') {
                 return false;
             } else {
                 if ($type != null && !in_array($contents['content_type'], $type)) {
                     return false;
                 } else {
                     $result = file_put_contents($this->getFilename($scope_id, $key, ".unknown"), $contents);
                     return $result;
                 }
             }
         }
     } catch (Exception $exception) {
         return false;
     }
 }
Example #3
0
 public function setByReference($scope_id, $reference, $type = null)
 {
     // TODO make sure valid content
     try {
         $contents = CacheUtils::fetch($reference);
         if ($contents === false) {
             return false;
         } else {
             if ($contents['http_code'] != '200') {
                 return false;
             } else {
                 if ($type != null && !in_array($contents['content_type'], $type)) {
                     return false;
                 } else {
                     $result = $this->cache->save($contents['body'], $this->makeKey($scope_id, $reference));
                     return $result;
                 }
             }
         }
     } catch (Exception $exception) {
         return false;
     }
 }