diff options
Diffstat (limited to 'system/database/DB_cache.php')
-rwxr-xr-x[-rw-r--r--] | system/database/DB_cache.php | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index d3968b315..3bf065ca5 100644..100755 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,14 +32,14 @@ class CI_DB_Cache { * * Grabs the CI super object instance so we can access it. * - */ + */ function CI_DB_Cache(&$db) { // Assign the main CI object to $this->CI // and load the file helper since we use it a lot $this->CI =& get_instance(); $this->db =& $db; - $this->CI->load->helper('file'); + $this->CI->load->helper('file'); } // -------------------------------------------------------------------- @@ -50,7 +50,7 @@ class CI_DB_Cache { * @access public * @param string the path to the cache directory * @return bool - */ + */ function check_path($path = '') { if ($path == '') @@ -59,10 +59,10 @@ class CI_DB_Cache { { return $this->db->cache_off(); } - + $path = $this->db->cachedir; } - + // Add a trailing slash to the path if needed $path = preg_replace("/(.+?)\/*$/", "\\1/", $path); @@ -71,11 +71,11 @@ class CI_DB_Cache { // If the path is wrong we'll turn off caching return $this->db->cache_off(); } - + $this->db->cachedir = $path; return TRUE; } - + // -------------------------------------------------------------------- /** @@ -95,18 +95,18 @@ class CI_DB_Cache { } $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); - + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); - - $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); - + + $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); + if (FALSE === ($cachedata = read_file($filepath))) - { + { return FALSE; } - - return unserialize($cachedata); - } + + return unserialize($cachedata); + } // -------------------------------------------------------------------- @@ -124,29 +124,29 @@ class CI_DB_Cache { } $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); - + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); - + $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; - + $filename = md5($sql); - + if ( ! @is_dir($dir_path)) { if ( ! @mkdir($dir_path, DIR_WRITE_MODE)) { return FALSE; } - - @chmod($dir_path, DIR_WRITE_MODE); + + @chmod($dir_path, DIR_WRITE_MODE); } - + if (write_file($dir_path.$filename, serialize($object)) === FALSE) { return FALSE; } - - @chmod($dir_path.$filename, DIR_WRITE_MODE); + + @chmod($dir_path.$filename, FILE_WRITE_MODE); return TRUE; } @@ -159,19 +159,19 @@ class CI_DB_Cache { * @return bool */ function delete($segment_one = '', $segment_two = '') - { + { if ($segment_one == '') { $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); } - + if ($segment_two == '') { $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); } - + $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; - + delete_files($dir_path, TRUE); } |