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

[PLATI-1363] Use Identity as the default compressor & serializer #5

Open
wants to merge 2 commits into
base: braze-main
Choose a base branch
from

Conversation

felixmo
Copy link

@felixmo felixmo commented Jan 28, 2025

Changes in Rails 7.1 prevent us from passing these in from platform so this change adds the Identity serializer/compressor and makes it the default.

@felixmo felixmo changed the title Use Identity as the default compressor & serializer [PLATI-1363] Use Identity as the default compressor & serializer Jan 28, 2025
@felixmo felixmo marked this pull request as ready for review January 28, 2025 17:16
@@ -26,12 +26,12 @@ class Server
:value_max_bytes => 1024 * 1024,
# surpassing value_max_bytes either warns (false) or throws (true)
:error_when_over_max_size => false,
:compressor => Compressor,
:compressor => (defined?($TESTING) && $TESTING) ? Compressor : Dalli::Identity,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dalli's pattern seems to be omitting the shared module prefix.

Suggested change
:compressor => (defined?($TESTING) && $TESTING) ? Compressor : Dalli::Identity,
:compressor => (defined?($TESTING) && $TESTING) ? Compressor : Identity,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should arguably update the tests to pass Compressor instead of use the default, if they fail otherwise. I don't feel particularly strongly about that though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that initially but it required a good amount of changes. I think we should probably keep the number of changes to a minimum to avoid diverging from upstream too much. Also I think doing it this way will allow us to bring in changes from upstream more easily in the future.

lib/dalli/server.rb Outdated Show resolved Hide resolved
Copy link

@jasonpenny jasonpenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in Rails 7.1 prevent us from passing these in from platform so this change adds the Identity serializer/compressor and makes it the default.

Can you explain more about this?

I would rather stop the bleeding (more and more changes to our fork diverging from upstream). I have to imagine that the newer version of dalli works with newer Rails and does not have an Identify compressor nor serializer.

@felixmo
Copy link
Author

felixmo commented Feb 3, 2025

@jasonpenny We currently use ZstdSerializer as the :coder to handle both serialization and compression.

Dalli, by default, also uses its own serializer & compressor. I think to avoid serializing & compressing entries twice we've been passing in Identity to override the default :serializer & :compressor.

But as of Rails 7.1, we can only specify either a :coder or (:serializer & :compressor) but not both: https://api.rubyonrails.org/v7.1/classes/ActiveSupport/Cache/Store.html#method-c-new (see description for :coder)

cc @naveg

@felixmo felixmo requested a review from naveg February 3, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants