Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Additional refactoring and code removal.

  • Loading branch information...
commit 95f8ed5b5594118ee9249f1c04c360d45a95a92c 1 parent 0ba622b
@markstory markstory authored
Showing with 2 additions and 40 deletions.
  1. +1 −34 cake/libs/cache.php
  2. +1 −6 cake/tests/cases/libs/cache.test.php
View
35 cake/libs/cache.php
@@ -196,37 +196,6 @@ function drop($name) {
}
/**
- * 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
*
* @param $name Name of the engine (without 'Engine')
@@ -245,7 +214,6 @@ function __loadEngine($name, $plugin = null) {
}
}
-
/**
* 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 @@ function set($settings = array(), $value = null) {
*/
function gc() {
$self =& Cache::getInstance();
- $config = $self->config();
- $self->_Engine[$config['engine']]->gc();
+ $self->_engines[$self->__name]->gc();
}
/**
View
7 cake/tests/cases/libs/cache.test.php
@@ -43,8 +43,6 @@ function setUp() {
$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 @@ function setUp() {
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_defaultCacheConfig['settings']);
- Cache::engine('File');
}
/**
@@ -211,7 +208,7 @@ function testConfigured() {
* @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 @@ function testInitSettings() {
'isWindows' => DIRECTORY_SEPARATOR == '\\'
);
$this->assertEqual($settings, $expecting);
-
- Cache::engine('File');
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.