예제 #1
0
 public function clear($key = null)
 {
     // return true if the cache is already empty
     if (!($driver = $this->getDriver())) {
         return true;
     }
     if (!isset($key)) {
         unset($driver);
         $this->driver = null;
         $this->driver = false;
         ehough_stash_Utilities::deleteRecursive($this->path);
     } else {
         $driver->query("DELETE FROM cacheStore WHERE key LIKE '{$key}%'");
     }
     return true;
 }
예제 #2
0
 /**
  * This function clears the data from a key. If a key points to both a directory and a file, both are erased. If
  * passed null, the entire cache directory is removed.
  *
  * @param  null|array $key
  * @return bool
  */
 public function clear($key = null)
 {
     $path = $this->makePath($key);
     if (is_file($path)) {
         $return = true;
         unlink($path);
     }
     if (strpos($path, '.php') !== false) {
         $path = substr($path, 0, -4);
     }
     if (is_dir($path)) {
         return ehough_stash_Utilities::deleteRecursive($path);
     }
     return isset($return);
 }
예제 #3
0
 public static function tearDownAfterClass()
 {
     ehough_stash_Utilities::deleteRecursive(ehough_stash_Utilities::getBaseDirectory());
 }
예제 #4
0
 public function testCheckEmptyDirectory()
 {
     $tmp = sys_get_temp_dir() . '/stash/';
     $dir2 = $tmp . 'emptytest/';
     @mkdir($dir2, 0770, true);
     $this->assertTrue(ehough_stash_Utilities::checkForEmptyDirectory($dir2), 'Returns true for empty directories');
     $this->assertFalse(ehough_stash_Utilities::checkForEmptyDirectory($tmp), 'Returns false for non-empty directories');
     ehough_stash_Utilities::deleteRecursive($tmp);
 }
예제 #5
0
파일: FileSystem.php 프로젝트: ehough/stash
 /**
  * This function clears the data from a key. If a key points to both a directory and a file, both are erased. If
  * passed null, the entire cache directory is removed.
  *
  * {@inheritdoc}
  */
 public function clear($key = null)
 {
     $path = $this->makePath($key);
     if (is_file($path)) {
         $return = true;
         unlink($path);
     }
     $extension = $this->getEncoder()->getExtension();
     if (strpos($path, $extension) !== false) {
         $path = substr($path, 0, -strlen($extension));
     }
     if (is_dir($path)) {
         return ehough_stash_Utilities::deleteRecursive($path, true);
     }
     return isset($return);
 }