Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Created August 11, 2020 02:00
Show Gist options
  • Save mttjohnson/935c047ba20ed6a79fa5b291e6b85455 to your computer and use it in GitHub Desktop.
Save mttjohnson/935c047ba20ed6a79fa5b291e6b85455 to your computer and use it in GitHub Desktop.
PHP Redis Compression Support and Validation
# When installing php redis via pecl the installation prompts for configuration options
pecl install redis
# Some PECL installation methods such as Ansible pecl_module do not allow
# for configuration options to be passed in during the installation
# Check for php redis supported compression types
PHP_CODE=$(cat <<'PHP_CODE'
<?php
echo "Redis Support:\n";
echo defined('Redis::SERIALIZER_IGBINARY') ? "igbinary supported\n" : "igbinary not available\n";
echo defined('Redis::COMPRESSION_LZF') ? "lzf supported\n" : "lzf not available\n";
echo defined('Redis::COMPRESSION_ZSTD') ? "zstd supported\n" : "zstd not available\n";
echo defined('Redis::COMPRESSION_LZ4') ? "lz4 supported\n" : "lz4 not available\n";
PHP_CODE
)
echo "${PHP_CODE}" | php
# To reinstall pecl redis with igbinary, lzf, and zstd support
pecl uninstall redis && printf "yes\nyes\nyes\n" | pecl install redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment