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: always convert underlying values into an Entry #42559

Merged
merged 1 commit into from Jun 22, 2021

Commits on Jun 22, 2021

  1. MemCacheStore: always convert underlying values into an Entry

    There's a bug in the Mem Cache Store on 6.1, I haven't confirmed if it exists on `main` too (since rails#42025).
    
    We came across the bug when upgrading an app from 6.0 to 6.1 that had recently switched from the `dalli_store` to the `mem_cache_store`. petergoldstein/dalli#771 seems similar, but in our case it's specifically to do with caching the value `false`.
    
    To replicate:
    
    - Open a Rails console with the `dalli_store` enabled.
    - `Rails.cache.write "test", false`
    - Open another Rails console, with the `mem_cache_store` enabled.
    - Enable the local cache (starting a Rails server would also achieve this): `ActiveSupport::Cache::Strategy::LocalCache::LocalCacheRegistry.set_cache_for(Rails.cache.send(:local_cache_key), ActiveSupport::Cache::Strategy::LocalCache::LocalStore.new)`
    - ` Rails.cache.fetch("test") { false }`
    
    It will crash with `NoMethodError (undefined method `dup_value!' for false:FalseClass)`.
    
    The fix is to convert any entry into an `Entry`, even if it's `nil` or `false`.
    ghiculescu committed Jun 22, 2021
    Copy the full SHA
    e60f3ff View commit details
    Browse the repository at this point in the history