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

MemCacheStore shorten keys properly #45245

Merged
merged 1 commit into from
Jun 9, 2022
Merged

Conversation

akostadinov
Copy link
Contributor

@akostadinov akostadinov commented Jun 2, 2022

The logic for shortening long keys in MemCacheStore
is broken since the time it stopped using MD5 checksumming.

Memcached supports keys up to 250 chars length. The reason
things worked I believe is because the underlying Dalli
library is doing it's own key shortening. Which uses its own
hashing function and in fact limits keys to 249 chars, see
petergoldstein/dalli@74b2625

This patch in a similar way properly truncates keys to 250
characters and avoids double hashing on Dalli side. Also
makes key name more predictable and independent from the
underlying Dalli version.

@akostadinov
Copy link
Contributor Author

I have also split tests into separate methods. Thank you for the input.

@byroot
Copy link
Member

byroot commented Jun 9, 2022

Please squash your commits, and I'll happily merge.

The logic for shortening long keys in MemCacheStore
is broken since the time it stopped using MD5 checksumming.

Memcached supports keys up to 250 chars length. The reason
things worked I believe is because the underlying Dalli
library is doing it's own key shortening. Which uses its own
hashing function and in fact limits keys to 249 chars, see
petergoldstein/dalli@74b2625

This patch in a similar way properly truncates keys to 250
characters and avoids double hashing on Dalli side. Also
makes key name more predictable and independent from the
underlying Dalli version.
@akostadinov
Copy link
Contributor Author

squashed, thanks!

@byroot byroot merged commit 34fb4c4 into rails:main Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants