From 08fea3c33572d9a002d2b184b7f282b687be6baa Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 14 Nov 2005 22:10:28 +0000 Subject: [PATCH] Implement wp_cache_flush(). git-svn-id: http://svn.automattic.com/wordpress/trunk@3087 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/cache.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/wp-includes/cache.php b/wp-includes/cache.php index 672380709e..0cdddfeff9 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -19,6 +19,8 @@ function wp_cache_delete($id, $flag = '') { function wp_cache_flush() { global $wp_object_cache; + + return $wp_object_cache->flush(); } function wp_cache_get($id, $flag = '') { @@ -88,6 +90,10 @@ class WP_Object_Cache { return true; } + function flush() { + return $this->rm($this->cache_dir . '*'); + } + function get($id, $group = 'default', $count_hits = true) { if ( empty($group) ) $group = 'default'; @@ -198,6 +204,27 @@ class WP_Object_Cache { return $this->cache_dir . "$group_dir/"; } + function rm($fileglob) { + if (is_file($fileglob)) { + return @unlink($fileglob); + } else if (is_dir($fileglob)) { + $ok = $this->rm("$fileglob/*"); + if (! $ok) { + return false; + } + return @rmdir($fileglob); + } else { + $matching = glob($fileglob); + if ($matching === false) + return true; + $rcs = array_map(array('WP_Object_Cache', 'rm'), $matching); + if (in_array(false, $rcs)) { + return false; + } + } + return true; + } + function replace($id, $data, $group = 'default', $expire = '') { if ( empty($group) ) $group = 'default';