diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-30 01:19:35 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-30 01:19:35 +0100 |
commit | b37d2bc462af918276111d0439592aa445ac6277 (patch) | |
tree | aed6d4d3fae2c8d43d2ba10b41240058d79ffd71 /system/core | |
parent | 4173823ba1b45955d63cb5e8d60f02312e345bda (diff) |
Add CI_Output::delete_cache()
(an improved version of PR #609)
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Output.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/system/core/Output.php b/system/core/Output.php index 7bfde07c7..98deff55c 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -627,6 +627,45 @@ class CI_Output { // -------------------------------------------------------------------- /** + * Delete cache + * + * @param string $uri URI string + * @return bool + */ + public function delete_cache($uri = '') + { + $CI =& get_instance(); + $cache_path = $CI->config->item('cache_path'); + if ($cache_path === '') + { + $cache_path = APPPATH.'cache/'; + } + + if ( ! is_dir($cache_path)) + { + log_message('error', 'Unable to find cache path: '.$cache_path); + return FALSE; + } + + if (empty($uri)) + { + $uri = $CI->uri->uri_string(); + } + + $cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').$uri); + + if ( ! @unlink($cache_path)) + { + log_message('error', 'Unable to delete cache file for '.$uri); + return FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** * Set Cache Header * * Set the HTTP headers to match the server-side file cache settings |