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; }
/** * 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); }
public static function tearDownAfterClass() { ehough_stash_Utilities::deleteRecursive(ehough_stash_Utilities::getBaseDirectory()); }
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); }
/** * 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); }