Skip to content

Commit 3f01f75

Browse files
committed
Settings -> Config for Cache namespace
1 parent 3a2dbec commit 3f01f75

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/Cache/CacheEngine.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,24 @@ public function groups() {
169169
/**
170170
* Cache Engine config
171171
*
172-
* @return array config
173-
*/
174-
public function config() {
175-
return $this->_config;
172+
* If called with no arguments, returns the full config array
173+
* Otherwise returns the config for the specified key
174+
*
175+
* Usage:
176+
* {{{
177+
* $instance->config(); will return full config
178+
* $instance->config('duration'); will return configured duration
179+
* $instance->config('notset'); will return null
180+
* }}}
181+
*
182+
* @param string|null $key to return
183+
* @return mixed array or config value
184+
*/
185+
public function config($key = null) {
186+
if ($key === null) {
187+
return $this->_config;
188+
}
189+
return isset($this->_config[$key]) ? $this->_config[$key] : null;
176190
}
177191

178192
/**

tests/TestCase/Cache/CacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public function testGroupConfigsThrowsException() {
275275

276276
/**
277277
* test that configured returns an array of the currently configured cache
278-
* settings
278+
* config
279279
*
280280
* @return void
281281
*/

tests/TestCase/Cache/Engine/MemcachedEngineTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ public function testMsgpackSerializerSetting() {
242242
);
243243

244244
$Memcached = new TestMemcachedEngine();
245-
$settings = array(
245+
$config = array(
246246
'engine' => 'Memcached',
247247
'servers' => array('127.0.0.1:11211'),
248248
'persistent' => false,
249249
'serialize' => 'msgpack'
250250
);
251251

252-
$Memcached->init($settings);
252+
$Memcached->init($config);
253253
$this->assertEquals(Memcached::SERIALIZER_MSGPACK, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER));
254254
}
255255

@@ -290,7 +290,7 @@ public function testMsgpackSerializerThrowException() {
290290
);
291291

292292
$Memcached = new TestMemcachedEngine();
293-
$settings = array(
293+
$config = array(
294294
'engine' => 'Memcached',
295295
'servers' => array('127.0.0.1:11211'),
296296
'persistent' => false,
@@ -300,7 +300,7 @@ public function testMsgpackSerializerThrowException() {
300300
$this->setExpectedException(
301301
'Cake\Error\Exception', 'msgpack is not a valid serializer engine for Memcached'
302302
);
303-
$Memcached->init($settings);
303+
$Memcached->init($config);
304304
}
305305

306306
/**

0 commit comments

Comments
 (0)