This project is archived and is in readonly mode.

#5588 open
Mike Perham

Integrate support for Dalli

Reported by Mike Perham | September 9th, 2010 @ 06:05 AM | in 3.1

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

Comments and changes to this ticket

  • Rohit Arondekar

    Rohit Arondekar September 12th, 2010 @ 05:16 AM

    • Importance changed from “” to “Low”

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

  • Mike Perham

    Mike Perham September 14th, 2010 @ 04:08 PM

    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.

  • Jeremy Kemper

    Jeremy Kemper September 14th, 2010 @ 08:24 PM

    • Milestone cleared.
    • State changed from “new” to “open”
    • Assigned user set to “Jeremy Kemper”
  • Mike Perham

    Mike Perham September 16th, 2010 @ 05:50 AM

    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.

  • Ryan Bigg

    Ryan Bigg October 11th, 2010 @ 10:55 AM

    Automatic cleanup of spam.

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:02 PM

    • Milestone set to 3.0.2
  • Ryan Bigg

    Ryan Bigg October 16th, 2010 @ 02:38 AM

    • Tag cleared.

    Automatic cleanup of spam.

  • Aaron Gibralter
  • Aaron Gibralter

    Aaron Gibralter October 29th, 2010 @ 11:58 PM

    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...

  • Mike Perham

    Mike Perham October 30th, 2010 @ 12:04 AM

    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.

  • Aaron Gibralter

    Aaron Gibralter October 30th, 2010 @ 12:04 AM

    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.)

  • Mike Perham

    Mike Perham October 30th, 2010 @ 12:14 AM

    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.

  • Aaron Gibralter

    Aaron Gibralter October 30th, 2010 @ 12:15 AM

    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.

  • Jeff Kreeftmeijer
  • Santiago Pastorino
  • Santiago Pastorino
  • Santiago Pastorino

    Santiago Pastorino January 9th, 2011 @ 10:45 PM

    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?

  • Mike Perham

    Mike Perham January 9th, 2011 @ 11:20 PM

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

  • rails

    rails April 10th, 2011 @ 01:00 AM

    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.

  • rails

    rails April 10th, 2011 @ 01:00 AM

    • State changed from “open” to “stale”
  • Santiago Pastorino

    Santiago Pastorino April 10th, 2011 @ 04:09 PM

    • State changed from “stale” to “open”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages