Merge remote-tracking branch 'tploch/2.0-memcache' into 2.0

This commit is contained in:
mark_story 2011-05-13 21:48:41 -04:00
commit 23d9e5d769
4 changed files with 6 additions and 2 deletions

View file

@ -279,6 +279,7 @@
* 'servers' => array( * 'servers' => array(
* '127.0.0.1:11211' // localhost, default port 11211 * '127.0.0.1:11211' // localhost, default port 11211
* ), //[optional] * ), //[optional]
* 'persistent' => true, // [optional] set this to false for non-persistent connections
* 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory) * 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
* )); * ));
* *

View file

@ -64,6 +64,7 @@ class MemcacheEngine extends CacheEngine {
'engine'=> 'Memcache', 'engine'=> 'Memcache',
'prefix' => Inflector::slug(APP_DIR) . '_', 'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array('127.0.0.1'), 'servers' => array('127.0.0.1'),
'persistent' => true,
'compress'=> false 'compress'=> false
), $settings) ), $settings)
); );
@ -79,7 +80,7 @@ class MemcacheEngine extends CacheEngine {
$this->_Memcache = new Memcache(); $this->_Memcache = new Memcache();
foreach ($this->settings['servers'] as $server) { foreach ($this->settings['servers'] as $server) {
list($host, $port) = $this->_parseServerString($server); list($host, $port) = $this->_parseServerString($server);
if ($this->_Memcache->addServer($host, $port)) { if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
$return = true; $return = true;
} }
} }

View file

@ -279,6 +279,7 @@
* 'servers' => array( * 'servers' => array(
* '127.0.0.1:11211' // localhost, default port 11211 * '127.0.0.1:11211' // localhost, default port 11211
* ), //[optional] * ), //[optional]
* 'persistent' => true, // [optional] set this to false for non-persistent connections
* 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory) * 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
* )); * ));
* *

View file

@ -50,7 +50,7 @@ class MemcacheEngineTest extends CakeTestCase {
* @return void * @return void
*/ */
function setUp() { function setUp() {
$this->skipIf(!class_exists('Memcache'), '%s Apc is not installed or configured properly'); $this->skipIf(!class_exists('Memcache'), '%s Memcache is not installed or configured properly');
$this->_cacheDisable = Configure::read('Cache.disable'); $this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false); Configure::write('Cache.disable', false);
Cache::config('memcache', array( Cache::config('memcache', array(
@ -86,6 +86,7 @@ class MemcacheEngineTest extends CakeTestCase {
'duration'=> 3600, 'duration'=> 3600,
'probability' => 100, 'probability' => 100,
'servers' => array('127.0.0.1'), 'servers' => array('127.0.0.1'),
'persistent' => true,
'compress' => false, 'compress' => false,
'engine' => 'Memcache' 'engine' => 'Memcache'
); );