mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-17 06:59:51 +00:00
Merge pull request #3560 from cakephp/2.6-memcached-options
2.6 memcached options
This commit is contained in:
commit
05d92ddc0a
2 changed files with 28 additions and 2 deletions
|
@ -45,6 +45,8 @@ class MemcachedEngine extends CacheEngine {
|
||||||
* - serialize = string, default => php. The serializer engine used to serialize data.
|
* - serialize = string, default => php. The serializer engine used to serialize data.
|
||||||
* Available engines are php, igbinary and json. Beside php, the memcached extension
|
* Available engines are php, igbinary and json. Beside php, the memcached extension
|
||||||
* must be compiled with the appropriate serializer support.
|
* must be compiled with the appropriate serializer support.
|
||||||
|
* - options - Additional options for the memcached client. Should be an array of option => value.
|
||||||
|
* Use the Memcached::OPT_* constants as keys.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -92,7 +94,8 @@ class MemcachedEngine extends CacheEngine {
|
||||||
'persistent' => false,
|
'persistent' => false,
|
||||||
'login' => null,
|
'login' => null,
|
||||||
'password' => null,
|
'password' => null,
|
||||||
'serialize' => 'php'
|
'serialize' => 'php',
|
||||||
|
'options' => array()
|
||||||
);
|
);
|
||||||
parent::init($settings);
|
parent::init($settings);
|
||||||
|
|
||||||
|
@ -128,6 +131,11 @@ class MemcachedEngine extends CacheEngine {
|
||||||
}
|
}
|
||||||
$this->_Memcached->setSaslAuthData($this->settings['login'], $this->settings['password']);
|
$this->_Memcached->setSaslAuthData($this->settings['login'], $this->settings['password']);
|
||||||
}
|
}
|
||||||
|
if (is_array($this->settings['options'])) {
|
||||||
|
foreach ($this->settings['options'] as $opt => $value) {
|
||||||
|
$this->_Memcached->setOption($opt, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,8 @@ class MemcachedEngineTest extends CakeTestCase {
|
||||||
'login' => null,
|
'login' => null,
|
||||||
'password' => null,
|
'password' => null,
|
||||||
'groups' => array(),
|
'groups' => array(),
|
||||||
'serialize' => 'php'
|
'serialize' => 'php',
|
||||||
|
'options' => array()
|
||||||
);
|
);
|
||||||
$this->assertEquals($expecting, $settings);
|
$this->assertEquals($expecting, $settings);
|
||||||
}
|
}
|
||||||
|
@ -133,6 +134,23 @@ class MemcachedEngineTest extends CakeTestCase {
|
||||||
$this->assertTrue($MemcachedCompressed->getMemcached()->getOption(Memcached::OPT_COMPRESSION));
|
$this->assertTrue($MemcachedCompressed->getMemcached()->getOption(Memcached::OPT_COMPRESSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test setting options
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testOptionsSetting() {
|
||||||
|
$memcached = new TestMemcachedEngine();
|
||||||
|
$memcached->init(array(
|
||||||
|
'engine' => 'Memcached',
|
||||||
|
'servers' => array('127.0.0.1:11211'),
|
||||||
|
'options' => array(
|
||||||
|
Memcached::OPT_BINARY_PROTOCOL => true
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$this->assertEquals(1, $memcached->getMemcached()->getOption(Memcached::OPT_BINARY_PROTOCOL));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test accepts only valid serializer engine
|
* test accepts only valid serializer engine
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue