Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support replacing cache compressor #48451

Merged
merged 1 commit into from
Jul 26, 2023

Commits on Jul 26, 2023

  1. Support replacing cache compressor

    This commit adds support for replacing the compressor used for
    serialized cache entries.  Custom compressors must respond to `deflate`
    and `inflate`.  For example:
    
      ```ruby
      module MyCompressor
        def self.deflate(string)
          # compression logic...
        end
    
        def self.inflate(compressed)
          # decompression logic...
        end
      end
    
      config.cache_store = :redis_cache_store, { compressor: MyCompressor }
      ```
    
    As part of this work, cache stores now also support a `:serializer`
    option.  Similar to the `:coder` option, serializers must respond to
    `dump` and `load`. However, serializers are only responsible for
    serializing a cached value, whereas coders are responsible for
    serializing the entire `ActiveSupport::Cache::Entry` instance.
    Additionally, the output from serializers can be automatically
    compressed, whereas coders are responsible for their own compression.
    
    Specifying a serializer instead of a coder also enables performance
    optimizations, including the bare string optimization introduced by cache
    format version 7.1.
    jonathanhefner committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    3efb844 View commit details
    Browse the repository at this point in the history