From 06d4e5e5531b1fcee464495fa6e83a372e3cb904 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 14 Nov 2009 18:50:23 -0500 Subject: [PATCH] Reformatting code in memcache. Adding unset() to test case to remove unnecessary keys that can cause test failure. --- cake/libs/cache/memcache.php | 9 ++++++--- cake/tests/cases/libs/cache/memcache.test.php | 16 +++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cake/libs/cache/memcache.php b/cake/libs/cache/memcache.php index 2d70a6e86..831cfa2ed 100644 --- a/cake/libs/cache/memcache.php +++ b/cake/libs/cache/memcache.php @@ -61,7 +61,10 @@ class MemcacheEngine extends CacheEngine { return false; } parent::init(array_merge(array( - 'engine'=> 'Memcache', 'prefix' => Inflector::slug(APP_DIR) . '_', 'servers' => array('127.0.0.1'), 'compress'=> false + 'engine'=> 'Memcache', + 'prefix' => Inflector::slug(APP_DIR) . '_', + 'servers' => array('127.0.0.1'), + 'compress'=> false ), $settings) ); @@ -100,7 +103,7 @@ class MemcacheEngine extends CacheEngine { */ function write($key, &$value, $duration) { $expires = time() + $duration; - $this->__Memcache->set($key.'_expires', $expires, $this->settings['compress'], $expires); + $this->__Memcache->set($key . '_expires', $expires, $this->settings['compress'], $expires); return $this->__Memcache->set($key, $value, $this->settings['compress'], $expires); } /** @@ -112,7 +115,7 @@ class MemcacheEngine extends CacheEngine { */ function read($key) { $time = time(); - $cachetime = intval($this->__Memcache->get($key.'_expires')); + $cachetime = intval($this->__Memcache->get($key . '_expires')); if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) { return false; } diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php index 8a48df86c..d26f360e8 100644 --- a/cake/tests/cases/libs/cache/memcache.test.php +++ b/cake/tests/cases/libs/cache/memcache.test.php @@ -82,13 +82,15 @@ class MemcacheEngineTest extends CakeTestCase { */ function testSettings() { $settings = Cache::settings(); - $expecting = array('prefix' => 'cake_', - 'duration'=> 3600, - 'probability' => 100, - 'servers' => array('127.0.0.1'), - 'compress' => false, - 'engine' => 'Memcache' - ); + unset($settings['serialize'], $settings['path']); + $expecting = array( + 'prefix' => 'cake_', + 'duration'=> 3600, + 'probability' => 100, + 'servers' => array('127.0.0.1'), + 'compress' => false, + 'engine' => 'Memcache' + ); $this->assertEqual($settings, $expecting); } /**