Example #1
0
 /**
  * Saves the resource to 
  * @param type $resource
  */
 public function save(Resource $resource)
 {
     //add the proper namespace data
     $key = $resource->getKey()->getString();
     $data = $resource->getData();
     //store if it exists, else we add
     if (apc_exists($key)) {
         apc_store($key, $data);
     } else {
         apc_add($key, $data);
     }
 }
Example #2
0
 public function save(Resource $resource)
 {
     $key = $resource->getKey()->getString();
     $filename = $this->getFilePath();
     $directory = dirname($filename);
     if (!file_exists($directory)) {
         mkdir($directory, 0777, true);
     }
     $fh = fopen($filename, 'w+');
     //exceptional error... file permissions probably wrong
     if (!$fh) {
         throw new \Exception("Cannot load cache \"{$id}\" from filesystem.");
     }
     fwrite($fh, serialize($resource->getData()));
     fclose($fh);
 }