mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 11:02:40 +00:00
Add serializer option to Memcached Cache engine
Add option to select a serializer engine among php, json or igbinary
This commit is contained in:
parent
a7a6fcae8a
commit
bd3f005ab6
2 changed files with 121 additions and 3 deletions
|
@ -102,7 +102,8 @@ class MemcachedEngineTest extends CakeTestCase {
|
|||
'engine' => 'Memcached',
|
||||
'login' => null,
|
||||
'password' => null,
|
||||
'groups' => array()
|
||||
'groups' => array(),
|
||||
'serializer' => 'php'
|
||||
);
|
||||
$this->assertEquals($expecting, $settings);
|
||||
}
|
||||
|
@ -132,6 +133,90 @@ class MemcachedEngineTest extends CakeTestCase {
|
|||
$this->assertTrue($MemcachedCompressed->getMemcached()->getOption(Memcached::OPT_COMPRESSION));
|
||||
}
|
||||
|
||||
/**
|
||||
* test accepts only valid serializer engine
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidSerializerSetting() {
|
||||
$Memcached = new TestMemcachedEngine();
|
||||
$settings = array(
|
||||
'engine' => 'Memcached',
|
||||
'servers' => array('127.0.0.1:11211'),
|
||||
'persistent' => false,
|
||||
'serializer' => 'invalid_serializer'
|
||||
);
|
||||
|
||||
$this->setExpectedException(
|
||||
'CacheException', 'invalid_serializer is not a valid serializer engine for Memcached'
|
||||
);
|
||||
$Memcached->init($settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* testPhpSerializerSetting method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPhpSerializerSetting() {
|
||||
$Memcached = new TestMemcachedEngine();
|
||||
$settings = array(
|
||||
'engine' => 'Memcached',
|
||||
'servers' => array('127.0.0.1:11211'),
|
||||
'persistent' => false,
|
||||
'serializer' => 'php'
|
||||
);
|
||||
|
||||
$Memcached->init($settings);
|
||||
$this->assertEquals(Memcached::SERIALIZER_PHP, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER));
|
||||
}
|
||||
|
||||
/**
|
||||
* testPhpSerializerSetting method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonSerializerSetting() {
|
||||
$this->skipIf(
|
||||
!Memcached::HAVE_JSON,
|
||||
'Memcached extension is not compiled with json support'
|
||||
);
|
||||
|
||||
$Memcached = new TestMemcachedEngine();
|
||||
$settings = array(
|
||||
'engine' => 'Memcached',
|
||||
'servers' => array('127.0.0.1:11211'),
|
||||
'persistent' => false,
|
||||
'serializer' => 'json'
|
||||
);
|
||||
|
||||
$Memcached->init($settings);
|
||||
$this->assertEquals(Memcached::SERIALIZER_JSON, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER));
|
||||
}
|
||||
|
||||
/**
|
||||
* testPhpSerializerSetting method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIgbinarySerializerSetting() {
|
||||
$this->skipIf(
|
||||
!Memcached::HAVE_IGBINARY,
|
||||
'Memcached extension is not compiled with igbinary support'
|
||||
);
|
||||
|
||||
$Memcached = new TestMemcachedEngine();
|
||||
$settings = array(
|
||||
'engine' => 'Memcached',
|
||||
'servers' => array('127.0.0.1:11211'),
|
||||
'persistent' => false,
|
||||
'serializer' => 'igbinary'
|
||||
);
|
||||
|
||||
$Memcached->init($settings);
|
||||
$this->assertEquals(Memcached::SERIALIZER_IGBINARY, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER));
|
||||
}
|
||||
|
||||
/**
|
||||
* test using authentication without memcached installed with SASL support
|
||||
* throw an exception
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue