forked from extern/egroupware
* Admin: new function "Clear cache and register hooks", also called automatic when restoring a backup
This commit is contained in:
parent
b514745d01
commit
8c4125e75c
@ -116,13 +116,30 @@ class egw_cache_apc extends egw_cache_provider_check implements egw_cache_provid
|
||||
return apc_delete(self::key($keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data under given keys
|
||||
*
|
||||
* @param array $keys eg. array($level,$app,$location)
|
||||
* @return boolean true on success, false on error (eg. $key not set)
|
||||
*/
|
||||
function flush(array $keys)
|
||||
{
|
||||
//error_log(__METHOD__."(".array2string($keys).")");
|
||||
foreach(new APCIterator('user', $preg='/^'.preg_quote(self::key($keys).'/')) as $item)
|
||||
{
|
||||
//error_log(__METHOD__."(".array2string($keys).") preg='$preg': calling apc_delete('$item[key]')");
|
||||
apc_delete($item['key']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a single key from $keys
|
||||
*
|
||||
* @param array $keys
|
||||
* @return string
|
||||
*/
|
||||
private function key(array $keys)
|
||||
private static function key(array $keys)
|
||||
{
|
||||
return implode('::',$keys);
|
||||
}
|
||||
|
@ -114,6 +114,49 @@ class egw_cache_files extends egw_cache_provider_check implements egw_cache_prov
|
||||
return unlink($fname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data under given keys
|
||||
*
|
||||
* @param array $keys eg. array($level,$app,$location)
|
||||
* @return boolean true on success, false on error (eg. $key not set)
|
||||
*/
|
||||
function flush(array $keys)
|
||||
{
|
||||
$dir = $this->filename($keys, false);
|
||||
|
||||
return file_exists($dir) ? self::rm_recursive($dir) : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive delete a path
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean true on success, false otherwise
|
||||
*/
|
||||
private static function rm_recursive($path)
|
||||
{
|
||||
if (!is_dir($path))
|
||||
{
|
||||
return unlink($path);
|
||||
}
|
||||
foreach(scandir($path) as $file)
|
||||
{
|
||||
if ($file == '.' || $file == '..') continue;
|
||||
|
||||
$file = $path.'/'.$file;
|
||||
|
||||
if (is_dir($file))
|
||||
{
|
||||
if (!self::rm_recursive($file)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!unlink($path.'/'.$file)) return false;
|
||||
}
|
||||
}
|
||||
return rmdir($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a path from $keys and $basepath
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user