From 27baf04149d22f5b7a4e1213108013ac6c90131b Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 29 Mar 2014 21:54:39 +0000 Subject: [PATCH] Convert CacheEngine to use InstanceConfigSuite --- src/Cache/CacheEngine.php | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/src/Cache/CacheEngine.php b/src/Cache/CacheEngine.php index ade66da11cb..a1f18c73927 100644 --- a/src/Cache/CacheEngine.php +++ b/src/Cache/CacheEngine.php @@ -14,6 +14,7 @@ */ namespace Cake\Cache; +use Cake\Core\InstanceConfigTrait; use Cake\Utility\Inflector; /** @@ -22,14 +23,7 @@ */ abstract class CacheEngine { -/** - * Runtime config - * - * This is the config of a particular instance - * - * @var array - */ - protected $_config = []; + use InstanceConfigTrait; /** * The default cache configuration is overriden in most cache adapters. These are @@ -70,7 +64,8 @@ abstract class CacheEngine { * @return boolean True if the engine has been successfully initialized, false if not */ public function init($config = []) { - $this->_config = $config + $this->_defaultConfig; + $this->config($config); + if (!empty($this->_config['groups'])) { sort($this->_config['groups']); $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups'])); @@ -78,6 +73,7 @@ public function init($config = []) { if (!is_numeric($this->_config['duration'])) { $this->_config['duration'] = strtotime($this->_config['duration']) - time(); } + return true; } @@ -166,29 +162,6 @@ public function groups() { return $this->_config['groups']; } -/** - * Cache Engine config - * - * If called with no arguments, returns the full config array - * Otherwise returns the config for the specified key - * - * Usage: - * {{{ - * $instance->config(); will return full config - * $instance->config('duration'); will return configured duration - * $instance->config('notset'); will return null - * }}} - * - * @param string|null $key to return - * @return mixed array or config value - */ - public function config($key = null) { - if ($key === null) { - return $this->_config; - } - return isset($this->_config[$key]) ? $this->_config[$key] : null; - } - /** * Generates a safe key for use with cache engine storage engines. *