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.

Integrate support for Dalli

#5588

I've officially deprecated memcache-client in favor of my new gem, Dalli, for accessing memcached. Dalli is different from memcache-client in that it uses the new binary protocol in memcached 1.4 and supports managed environments like Heroku. Its API is mostly compatible with memcache-client with some minor exceptions and it uses the exact same algorithm to select a server so gem migrations should not invalidate 100% of existing cache.

I would like to discuss the changes necessary to remove/deprecate :mem_cache_store in favor of :dalli_store. DalliStore is shipped with the dalli gem itself. You can read more details here:

http://github.com/mperham/dalli

Reported by Mike Perham · September 9th, 2010 @ 06:05 AM

State: open
Milestone: 3.1
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • Importance changed from to Low

    I think this is better suited for the core mailing list: http://groups.google.com/group/rubyonrails-core

    September 12th, 2010 @ 05:16 AM

  2. Mike Perham
    Mike Perham

    I'm working on a patch to do the work. One issue I have found is that the increment/decrement operations are not backwards compatible. This is not a Dalli limitation but due to a change in the memcached binary protocol. Counters can no longer be initialized with set() and read with get(). They are 64-bit integers which can only be accessed with the incr/decr operations.

    I will hopefully have a first pass at the patch later this week.

    September 14th, 2010 @ 04:08 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to Jeremy Kemper

    September 14th, 2010 @ 08:24 PM

  4. Mike Perham
    Mike Perham

    My comments about increment/decrement were wrong. Further investigation found a bug in my code. So it goes.

    Here's a patch which deprecates :mem_cache_store when used with memcache-client. Since :mem_cache_store also supports fauna's memcached gem I didn't deprecate the entire class, just that codepath.

    The dalli_store test is identical to the mem_cache_store test and passes 100%.

    My goal is to make Dalli the new recommended production cache store in Rails 3.1. Please let me know if I can help with any bug, documentation or other changes to that end.

    September 16th, 2010 @ 05:50 AM

  5. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:55 AM

  6. Jeremy Kemper
  7. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 16th, 2010 @ 02:38 AM

  8. Aaron Gibralter
  9. Aaron Gibralter
    Aaron Gibralter

    Also, Mike, does Dalli open and keep open sockets to the memcache server during Rails initialization like the old memcache store? I'm just trying to wrangle a few tickets here... it would be great if Dalli as a session store didn't have the same issues as the old session/mem_cache_store: https://rails.lighthouseapp.com/projects/8994/tickets/2644-memcache...

    October 29th, 2010 @ 11:58 PM

  10. Mike Perham
    Mike Perham

    Dalli packages a dalli_store adapter for ActiveSupport. I'd guess that the Rails core is trying to move away from shipping adapters for specific gems - I'm ok with dalli_store remaining in the dalli gem itself but you can pull it into active_support if you'd like.

    And Dalli connects lazily to memcached. It will not open a socket until the code performs an actual operation. I also include a Dalli::Client#reset method that can be used in the Passenger fork event if necessary but it should only be needed in special cases.

    October 30th, 2010 @ 12:04 AM

  11. Aaron Gibralter
    Aaron Gibralter

    Could a new Dalli-based session store also address the session fixation issue: https://rails.lighthouseapp.com/projects/8994/tickets/3134-memcache...

    (Sorry for all the messages! Should have thought this all through before submitting.)

    October 30th, 2010 @ 12:04 AM

  12. Mike Perham
    Mike Perham

    That session ID bug looks like something that might be endemic to all session store providers and should be fixed generically. My general policy is to stay as compatible as possible with the mem_cache_store version - even if that means reproducing bugs. If Rails fixes mem_cache_store, I'll update dalli_store with the same fix.

    October 30th, 2010 @ 12:14 AM

  13. Aaron Gibralter
    Aaron Gibralter

    Yeah makes sense. I just think that Rails should deprecate and then gut the existing mem_cache_store (for activesupport and actionpack's sessions). Rails should ship with CookieStore and ActiveRecordStore... If someone wants memcache support, she can use dalli_store; and if she wants redis support, she can use redis-store -- it is as easy as putting the gems in her Gemfile.

    October 30th, 2010 @ 12:15 AM

  14. Jeff Kreeftmeijer
  15. Santiago Pastorino
  16. Santiago Pastorino
  17. Santiago Pastorino
    Santiago Pastorino

    Mike we were talking with Jeremy and Aaron and we come up with this ...

    "I just think that Rails should deprecate and then gut the existing mem_cache_store (for activesupport and actionpack's sessions). Rails should ship with CookieStore and ActiveRecordStore... If someone wants memcache support, she can use dalli_store; and if she wants redis support, she can use redis-store -- it is as easy as putting the gems in her Gemfile."

    What do you think?

    January 9th, 2011 @ 10:45 PM

  18. Mike Perham
    Mike Perham

    Sounds fine to me. You are welcome to point people to Dalli and :dalli_store in the deprecation warning.

    January 9th, 2011 @ 11:20 PM

  19. rails
    rails

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    April 10th, 2011 @ 01:00 AM

  20. rails
    rails
    • State changed from open to stale

    April 10th, 2011 @ 01:00 AM

  21. Santiago Pastorino
    Santiago Pastorino
    • State changed from stale to open

    April 10th, 2011 @ 04:09 PM