Additional refactoring and code removal.

This commit is contained in:
mark_story 2009-11-17 00:09:22 -05:00
parent 0ba622bb0e
commit 95f8ed5b55
2 changed files with 2 additions and 40 deletions

View file

@ -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();
}
/**

View file

@ -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');
}
/**