The project is in a healthy, maintained state
Drop-in Zlib compressor replacement for ActiveSupport::Cache
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 1.5, >= 1.5.6.6
 Project Readme

ActiveSupport::Cache::ZstdCompressor

A blazing-fast Zstandard compressor for ActiveSupport::Cache. Built for developers who appreciate both performance and the finer things in life, like not waiting forever for cache operations.

🚀 Blazing Speed

Decompression speeds that make LZ4 look sleepy.

🎯 Excellent Ratios

Better compression than gzip with less CPU drama.

⚡ Tunable Performance

30 compression levels from "ludicrous speed" to "maximum squeeze".

đź§  Smart Memory Usage

Uses modern amounts of RAM because it’s not 1995 anymore.

Installation

Install the gem and add to the application’s Gemfile by executing:

bundle add activesupport-cache-zstd_compressor

If bundler is not being used to manage dependencies, install the gem by executing:

gem install activesupport-cache-zstd_compressor

Usage

Rails.application.configure do
  config.cache_store = :redis_cache_store, {
  url:        ENV["REDIS_URL"],
  compress:   true,
  compressor: ActiveSupport::Cache::ZstdCompressor.new
}

By default, it uses compression level 3, but you can easily tweak it:

Rails.application.configure do
  config.cache_store = :redis_cache_store, {
  url:        ENV["REDIS_URL"],
  compress:   true,
  compressor: ActiveSupport::Cache::ZstdCompressor.new(level: 6)
}

Migrating from Rails default compressor (Zlib)

Tip
Perfect for production environments where cache invalidation is not an option.
Rails.application.configure do
  config.cache_store = :redis_cache_store, {
  url:        ENV["REDIS_URL"],
  compress:   true,
  compressor: ActiveSupport::Cache::ZstdCompressor::WithZlibFallback.new
}
How it works
  1. 🔍 Detects compressed data format by magic number

  2. đź“– Reads existing Zlib-compressed cache entries seamlessly

  3. ✍️ Writes all new entries using superior Zstd compression

Compatibility

This library aims to support and is tested against:

If something doesn’t work on one of these versions, it’s a bug.

This library may inadvertently work (or seem to work) on other Ruby versions, however support will only be provided for the versions listed above.

Development

bundle install
bundle exec rake

Contributing

  • Fork activesupport-cache-zstd_compressor

  • Make your changes

  • Ensure all tests pass (bundle exec rake)

  • Send a merge request

  • If we like them we’ll merge them

  • If we’ve accepted a patch, feel free to ask for commit access!

Acknowledgements

This library is inspired by https://github.com/pawurb/rails-brotli-cache