Skip to content

Commit

Permalink
[mms] Support msgpack for serializing the map lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 30, 2013
1 parent 4466571 commit 951c330
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
15 changes: 11 additions & 4 deletions framework/Autoloader_Cache/lib/Horde/Autoloader/Cache.php
Expand Up @@ -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;
}
Expand All @@ -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')) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
9 changes: 7 additions & 2 deletions framework/Autoloader_Cache/package.xml
Expand Up @@ -28,7 +28,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Support msgpack for serializing the map lookup.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -84,6 +84,11 @@
<min>1.5.2</min>
<providesextension>lzf</providesextension>
</package>
<package>
<name>msgpack</name>
<channel>pecl.php.net</channel>
<providesextension>msgpack</providesextension>
</package>
<extension>
<name>apc</name>
</extension>
Expand Down Expand Up @@ -289,7 +294,7 @@
<date>2013-08-20</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Support msgpack for serializing the map lookup.
</notes>
</release>
</changelog>
Expand Down

0 comments on commit 951c330

Please sign in to comment.