Ejemplo n.º 1
0
 /**
  *
  */
 protected function genHashFilename($base, $filename)
 {
     $extension = pathinfo($base . $filename, PATHINFO_EXTENSION);
     do {
         $path = sy_fix_path($base . $filename);
         $hash = md5($path . mktime());
         $path = sy_fix_path($base . '/' . $hash . '.' . $extension);
     } while (file_exists($path));
     return $hash . '.' . $extension;
 }
Ejemplo n.º 2
0
 /**
  * (non-PHPdoc)
  * @see CacheInterface::write()
  */
 public function write($id, $data = '', $ttl = null)
 {
     if (is_null($ttl)) {
         $ttl = $this->ttl;
     }
     $file = $this->findFile($id);
     $name = $id;
     if ($ttl) {
         $ttl += mktime();
         $name .= '_' . $ttl;
     }
     if (empty($file)) {
         $file = sy_fix_path($this->path . '/' . $name, 'php');
     } else {
         rename($file, $this->path . '/' . $name . '.php');
         $file = $this->path . '/' . $name . '.php';
     }
     if (!is_string($data)) {
         $data = serialize($data);
     }
     file_put_contents($file, $data);
 }