Skip to content

Commit

Permalink
Merge pull request #131 from mklooss/FEATURE-zstd
Browse files Browse the repository at this point in the history
added zstd as compress option
  • Loading branch information
colinmollenhour authored Apr 11, 2018
2 parents 873f5a2 + a9c4a5a commit 77a0e53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Cm/Cache/Backend/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ public function __construct($options = array())
}
$this->_compressionLib = 'l4z';
}
else if ( function_exists('zstd_compress')) {
$version = phpversion("zstd");
if (version_compare($version, "0.4.13") < 0)
{
$this->_compressTags = $this->_compressTags > 1 ? true : false;
$this->_compressData = $this->_compressData > 1 ? true : false;
}
$this->_compressionLib = 'zstd';
}
else if ( function_exists('lzf_compress') ) {
$this->_compressionLib = 'lzf';
}
Expand Down Expand Up @@ -1171,6 +1180,7 @@ protected function _encodeData($data, $level)
case 'snappy': $data = snappy_compress($data); break;
case 'lzf': $data = lzf_compress($data); break;
case 'l4z': $data = lz4_compress($data, $level); break;
case 'zstd': $data = zstd_compress($data, $level); break;
case 'gzip': $data = gzcompress($data, $level); break;
default: throw new CredisException("Unrecognized 'compression_lib'.");
}
Expand All @@ -1193,6 +1203,7 @@ protected function _decodeData($data)
case 'sn': return snappy_uncompress(substr($data,5));
case 'lz': return lzf_decompress(substr($data,5));
case 'l4': return lz4_uncompress(substr($data,5));
case 'zs': return zstd_uncompress(substr($data,5));
case 'gz': case 'zc': return gzuncompress(substr($data,5));
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Works with any Zend Framework project including all versions of Magento!
<compress_data>1</compress_data> <!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_tags>1</compress_tags> <!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_threshold>20480</compress_threshold> <!-- Strings below this size will not be compressed -->
<compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf, lz4 (as l4z) and snappy -->
<compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf, lz4 (as l4z), snappy and zstd -->
<use_lua>0</use_lua> <!-- Set to 1 if Lua scripts should be used for some operations (recommended) -->
<load_from_slave>tcp://redis-slave:6379</load_from_slave> <!-- Perform reads from a different server -->
</backend_options>
Expand Down

0 comments on commit 77a0e53

Please sign in to comment.