From 951c330688f8d948ffbbd348bc7101abd49c908e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 30 Oct 2013 01:28:34 -0600 Subject: [PATCH] [mms] Support msgpack for serializing the map lookup. --- .../lib/Horde/Autoloader/Cache.php | 15 +++++++++++---- framework/Autoloader_Cache/package.xml | 9 +++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/framework/Autoloader_Cache/lib/Horde/Autoloader/Cache.php b/framework/Autoloader_Cache/lib/Horde/Autoloader/Cache.php index be8bb414ea3..27af32c9765 100644 --- a/framework/Autoloader_Cache/lib/Horde/Autoloader/Cache.php +++ b/framework/Autoloader_Cache/lib/Horde/Autoloader/Cache.php @@ -119,7 +119,9 @@ public function __construct() } if ($data !== false) { - $data = @json_decode($data, true); + $data = extension_loaded('msgpack') + ? msgpack_unpack($data) + : @json_decode($data, true); if (is_array($data)) { $this->_cache = $data; } @@ -140,7 +142,9 @@ public function __destruct() return; } - $data = json_encode($this->_cache); + $data = extension_loaded('msgpack') + ? msgpack_pack($this->_cache) + : json_encode($this->_cache); if (extension_loaded('horde_lz4')) { $data = horde_lz4_compress($data); } elseif (extension_loaded('lzf')) { @@ -249,7 +253,10 @@ protected function _getKeylist() break; case self::TEMPFILE: - $keylist = @json_decode(@file_get_contents($this->_tempdir . '/' . self::KEYLIST), true); + $tmp = @file_get_contents($this->_tempdir . '/' . self::KEYLIST); + $keylist = extension_loaded('msgpack') + ? msgpack_unpack($tmp) + : @json_decode($tmp, true); break; } @@ -279,7 +286,7 @@ protected function _saveKeylist($keylist) break; case self::TEMPFILE: - file_put_contents($this->_tempdir . '/' . self::KEYLIST, json_encode($keylist)); + file_put_contents($this->_tempdir . '/' . self::KEYLIST, extension_loaded('msgpack') ? msgpack_pack($keylist) : json_encode($keylist)); break; } } diff --git a/framework/Autoloader_Cache/package.xml b/framework/Autoloader_Cache/package.xml index ad75d4df81c..a5259b95715 100644 --- a/framework/Autoloader_Cache/package.xml +++ b/framework/Autoloader_Cache/package.xml @@ -28,7 +28,7 @@ LGPL-2.1 -* +* [mms] Support msgpack for serializing the map lookup. @@ -84,6 +84,11 @@ 1.5.2 lzf + + msgpack + pecl.php.net + msgpack + apc @@ -289,7 +294,7 @@ 2013-08-20 LGPL-2.1 -* +* [mms] Support msgpack for serializing the map lookup.