Added 'persistent' setting to MemcacheEngine.

Fixes #1705 when connections are not closed when using i.e. FCGI.
This commit is contained in:
Thomas Ploch 2011-05-13 23:44:51 +02:00
parent 228230e67b
commit 402c4a7a6f
3 changed files with 5 additions and 2 deletions

View file

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

View file

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

View file

@ -50,7 +50,7 @@ class MemcacheEngineTest extends CakeTestCase {
* @return void
*/
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');
Configure::write('Cache.disable', false);
Cache::config('memcache', array(
@ -86,6 +86,7 @@ class MemcacheEngineTest extends CakeTestCase {
'duration'=> 3600,
'probability' => 100,
'servers' => array('127.0.0.1'),
'persistent' => true,
'compress' => false,
'engine' => 'Memcache'
);