Permalink
Browse files

Added msgpack support for Memcached

  • Loading branch information...
1 parent 3b8208b commit 7056ccd38a3f97584fd3ff9721988011b338af17 @davidsteinsland davidsteinsland committed Nov 19, 2013
@@ -60,6 +60,7 @@ class MemcachedEngine extends CacheEngine {
protected $_serializers = array(
'igbinary' => Memcached::SERIALIZER_IGBINARY,
'json' => Memcached::SERIALIZER_JSON,
+ 'msgpack' => Memcached::SERIALIZER_MSGPACK,
'php' => Memcached::SERIALIZER_PHP
);
@@ -218,6 +218,29 @@ public function testIgbinarySerializerSetting() {
}
/**
+ * testMsgpackSerializerSetting method
+ *
+ * @return void
+ */
+ public function testMsgpackSerializerSetting() {
+ $this->skipIf(
+ !Memcached::HAVE_MSGPACK,
+ 'Memcached extension is not compiled with msgpack support'
+ );
+
+ $Memcached = new TestMemcachedEngine();
+ $settings = array(
+ 'engine' => 'Memcached',
+ 'servers' => array('127.0.0.1:11211'),
+ 'persistent' => false,
+ 'serialize' => 'msgpack'
+ );
+
+ $Memcached->init($settings);
+ $this->assertEquals(Memcached::SERIALIZER_MSGPACK, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER));
+ }
+
+/**
* testJsonSerializerThrowException method
*
* @return void
@@ -243,6 +266,31 @@ public function testJsonSerializerThrowException() {
}
/**
+ * testMsgpackSerializerThrowException method
+ *
+ * @return void
+ */
+ public function testMsgpackSerializerThrowException() {
+ $this->skipIf(
+ Memcached::HAVE_MSGPACK,
+ 'Memcached extension is compiled with msgpack support'
+ );
+
+ $Memcached = new TestMemcachedEngine();
+ $settings = array(
+ 'engine' => 'Memcached',
+ 'servers' => array('127.0.0.1:11211'),
+ 'persistent' => false,
+ 'serialize' => 'msgpack'
+ );
+
+ $this->setExpectedException(
+ 'CacheException', 'Memcached extension is not compiled with msgpack support'
+ );
+ $Memcached->init($settings);
+ }
+
+/**
* testIgbinarySerializerThrowException method
*
* @return void

0 comments on commit 7056ccd

Please sign in to comment.