public function testLz4DriverDecompress()
 {
     try {
         $ob = new Horde_Compress_Fast(array('drivers' => array('Horde_Compress_Fast_Lz4')));
     } catch (Horde_Compress_Fast_Exception $e) {
         $this->markTestSkipped('Horde LZ4 extension not available.');
     }
     $this->assertEquals($this->compress_text, $ob->decompress(horde_lz4_compress($this->compress_text)));
     try {
         $ob->decompress(new stdClass());
         $this->fail('Expected exception.');
     } catch (Horde_Compress_Fast_Exception $e) {
     }
 }
Exemple #2
0
 public function testHighCompression()
 {
     // Compressing a big string
     $output = horde_lz4_compress($this->data, true);
     $this->assertEquals(0, strcmp(horde_lz4_uncompress($output), $this->data));
     // Compressing a smaller string
     $smallstring = "A small string to compress\n";
     $output = horde_lz4_compress($smallstring, true);
     $this->assertEquals(0, strcmp(horde_lz4_uncompress($output), $smallstring));
 }
Exemple #3
0
 /**
  * Set cached data.
  *
  * @param string $key  Cache key.
  * @param mixed $data  Data to store.
  *
  * @return boolean  True on success, false on failure.
  */
 public function set($key, $data)
 {
     $data = $this->_mask & self::MSGPACK ? msgpack_pack($data) : json_encode($data);
     if ($this->_mask & self::LZ4) {
         $data = @horde_lz4_compress($data);
     } elseif ($this->_mask & self::LZF) {
         $data = lzf_compress($data);
     }
     if ($this->_mask & self::APC) {
         return apc_store($key, $data);
     } elseif ($this->_mask & self::XCACHE) {
         return xcache_set($key, $data);
     } elseif ($this->_mask & self::EACCELERATOR) {
         eaccelerator_put($key, $data);
         return true;
     } elseif ($this->_mask & self::TEMPFILE) {
         return file_put_contents($this->_tempdir . '/' . $key, $data);
     }
     return false;
 }
Exemple #4
0
 /**
  */
 public function compress($text)
 {
     return strlen($text) ? horde_lz4_compress($text) : '';
 }