mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Reformatting code in memcache.
Adding unset() to test case to remove unnecessary keys that can cause test failure.
This commit is contained in:
parent
8b1a2b1f72
commit
06d4e5e553
2 changed files with 15 additions and 10 deletions
9
cake/libs/cache/memcache.php
vendored
9
cake/libs/cache/memcache.php
vendored
|
@ -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;
|
||||
}
|
||||
|
|
16
cake/tests/cases/libs/cache/memcache.test.php
vendored
16
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -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);
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue