Skip to content
Permalink
Browse files

Reformatting code in memcache.

Adding unset() to test case to remove unnecessary keys that can cause test failure.
  • Loading branch information...
markstory committed Nov 14, 2009
1 parent 8b1a2b1 commit 06d4e5e5531b1fcee464495fa6e83a372e3cb904
Showing with 15 additions and 10 deletions.
  1. +6 −3 cake/libs/cache/memcache.php
  2. +9 −7 cake/tests/cases/libs/cache/memcache.test.php
@@ -61,7 +61,10 @@ function init($settings = array()) {
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 @@ function init($settings = array()) {
*/
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 @@ function write($key, &$value, $duration) {
*/
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;
}
@@ -82,13 +82,15 @@ function tearDown() {
*/
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);
}
/**

0 comments on commit 06d4e5e

Please sign in to comment.
You can’t perform that action at this time.