From 95f8ed5b5594118ee9249f1c04c360d45a95a92c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 17 Nov 2009 00:09:22 -0500 Subject: [PATCH] Additional refactoring and code removal. --- cake/libs/cache.php | 35 +--------------------------- cake/tests/cases/libs/cache.test.php | 7 +----- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index b3bc49d32..b96e4d296 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -195,37 +195,6 @@ class Cache { return true; } -/** - * Set the cache engine to use or modify settings for one instance - * - * @param string $name Name of the engine (without 'Engine') - * @param array $settings Optional associative array of settings passed to the engine - * @return boolean True on success, false on failure - * @access public - * @static - */ - function engine($name = 'File', $settings = array()) { - $class = $name; - list($plugin, $class) = pluginSplit($name); - $cacheClass = $class . 'Engine'; - $self =& Cache::getInstance(); - if (!isset($self->_Engine[$name])) { - if ($self->__loadEngine($class, $plugin) === false) { - return false; - } - $self->_Engine[$name] =& new $cacheClass(); - } - - if ($self->_Engine[$name]->init($settings)) { - if (time() % $self->_Engine[$name]->settings['probability'] === 0) { - $self->_Engine[$name]->gc(); - } - return true; - } - $self->_Engine[$name] = null; - return false; - } - /** * Tries to find and include a file for a cache engine and returns object instance * @@ -245,7 +214,6 @@ class Cache { } } - /** * Temporarily change settings to current config options. if no params are passed, resets settings if needed * Cache::write() will reset the configuration changes made @@ -293,8 +261,7 @@ class Cache { */ function gc() { $self =& Cache::getInstance(); - $config = $self->config(); - $self->_Engine[$config['engine']]->gc(); + $self->_engines[$self->__name]->gc(); } /** diff --git a/cake/tests/cases/libs/cache.test.php b/cake/tests/cases/libs/cache.test.php index a63e9e666..4e575bc8c 100644 --- a/cake/tests/cases/libs/cache.test.php +++ b/cake/tests/cases/libs/cache.test.php @@ -43,8 +43,6 @@ class CacheTest extends CakeTestCase { $this->_defaultCacheConfig = Cache::config('default'); Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests')); - - Cache::engine('File', array('path' => TMP . 'tests')); } /** @@ -56,7 +54,6 @@ class CacheTest extends CakeTestCase { function tearDown() { Configure::write('Cache.disable', $this->_cacheDisable); Cache::config('default', $this->_defaultCacheConfig['settings']); - Cache::engine('File'); } /** @@ -211,7 +208,7 @@ class CacheTest extends CakeTestCase { * @return void */ function testInitSettings() { - Cache::engine('File', array('path' => TMP . 'tests')); + Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests')); $settings = Cache::settings(); $expecting = array( @@ -225,8 +222,6 @@ class CacheTest extends CakeTestCase { 'isWindows' => DIRECTORY_SEPARATOR == '\\' ); $this->assertEqual($settings, $expecting); - - Cache::engine('File'); } /**