Skip to content

Commit

Permalink
Settings -> Config for Cache namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Mar 20, 2014
1 parent 3a2dbec commit 3f01f75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
22 changes: 18 additions & 4 deletions src/Cache/CacheEngine.php
Expand Up @@ -169,10 +169,24 @@ public function groups() {
/**
* Cache Engine config
*
* @return array config
*/
public function config() {
return $this->_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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Cache/CacheTest.php
Expand Up @@ -275,7 +275,7 @@ public function testGroupConfigsThrowsException() {

/**
* test that configured returns an array of the currently configured cache
* settings
* config
*
* @return void
*/
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Cache/Engine/MemcachedEngineTest.php
Expand Up @@ -242,14 +242,14 @@ public function testMsgpackSerializerSetting() {
);

$Memcached = new TestMemcachedEngine();
$settings = array(
$config = array(
'engine' => 'Memcached',
'servers' => array('127.0.0.1:11211'),
'persistent' => false,
'serialize' => 'msgpack'
);

$Memcached->init($settings);
$Memcached->init($config);
$this->assertEquals(Memcached::SERIALIZER_MSGPACK, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER));
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public function testMsgpackSerializerThrowException() {
);

$Memcached = new TestMemcachedEngine();
$settings = array(
$config = array(
'engine' => 'Memcached',
'servers' => array('127.0.0.1:11211'),
'persistent' => false,
Expand All @@ -300,7 +300,7 @@ public function testMsgpackSerializerThrowException() {
$this->setExpectedException(
'Cake\Error\Exception', 'msgpack is not a valid serializer engine for Memcached'
);
$Memcached->init($settings);
$Memcached->init($config);
}

/**
Expand Down

0 comments on commit 3f01f75

Please sign in to comment.