Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add read_multi to ActiveSupport::Cache::Store

#3189

I currently run unit tests with MemoryStore, and production with MemCacheStore. I use the 'read_multi' method provided by MemCacheStore, but read_multi is only available to MemCacheStore, so the code breaks in tests.

I realize that I can fix my tests by always using :memcache_store, and wrapping every test using 'with_local_cache' (defined in ActiveSupport::Cache::Strategy::LocalCache). However, this method is not documented, and I'm not sure if developers should be using this. If I'm testing incorrectly, this ticket is awash.

This patch adds 'read_multi' to the Rails.cache API. It duplicates the memcache behavior in that the arguments are flattened, and nonexistent keys are not included in the results.

Reported by matthuhiggins · September 11th, 2009 @ 08:55 AM

State: resolved
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Medium

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from active_support to active_support, bugmash

    September 25th, 2009 @ 12:22 PM

  2. John Pignata
    John Pignata

    +1 on the change, verified that patch applies cleanly to master and tests pass

    September 26th, 2009 @ 10:16 PM

  3. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from new to open
    • Assigned user set to José Valim

    +1 on this patch.

    However, I found out that CompressedMemCacheStore tests doesn't work after apply your patch. So here's my another patch that adds documentation and proper read_multi to CompressedMemCacheStore

    You need to apply matthuhiggins patch, then my patch :) Both of them can be applied on 2-3-stable and master

    January 25th, 2010 @ 05:03 PM

  4. Rizwan Reza
    Rizwan Reza
    • Tag changed from active_support, bugmash to active_support

    January 25th, 2010 @ 05:06 PM

  5. José Valim
    José Valim
    • Assigned user changed from José Valim to Jeremy Kemper

    I have limited knowledge on cache stores, so I can't tell what is the proper fix. Assigning to Jeremy.

    February 2nd, 2010 @ 10:38 AM

  6. Jeremy Kemper
    Jeremy Kemper
    • State changed from open to resolved

    Thanks Matt :)

    April 28th, 2010 @ 06:05 AM