# Memcache storage failing across mongrels

**URL:** <https://www.ruby-forum.com/t/memcache-storage-failing-across-mongrels/91505>\
**Category:** Rails\
**Created:** [April 9, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/memcache-storage-failing-across-mongrels/91505 "2007-04-09T23:36:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chuck\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/87869e/32.png) [@Chuck\_V](https://www.ruby-forum.com/u/Chuck_V)\
**Post date:** [April 9, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/memcache-storage-failing-across-mongrels/91505/1 "2007-04-09T23:36:56Z")

</div>

We’ve been using memcached to store sessions across our mongrel  
cluster but we’ve noticed that when apache switches us to a different  
mongrel our session dies and we get logged out. Further, when I switch  
mongrels manually (using different ports) the same thing happens. I’ve  
been hunting around for the last couple of days on this but to no  
avail so I thought I would ask the experts.

There are two versions, the version from err’s blog and an updated one  
that seems like it’s more in line with memcache-client 1.3.0 options.  
They perform exactly the same.

Also below is a sample dump from memcached -vv

Thanks in advance for any advice!

Sincerely,  
Chuck V.

=====================

Here is my environment.rb:

Rails::Initializer.run do |config|  
config.action\_controller.session\_store = :mem\_cache\_store if  
RAILS\_ENV = ‘production’  
config.plugins = [“engines”,"\*"]  
end

memcache\_options = {  
:namespace =\> “nef\_#{RAILS\_ENV}”,  
:readonly =\> false,  
:multithread =\> true  
}

CACHE = MemCache.new(‘localhost:11211’, memcache\_options)

ActionController::Base.session\_options[:expires] = 1800  
ActionController::Base.session\_options[:cache] = CACHE

— OR —

Rails::Initializer.run do |config|  
config.action\_controller.session\_store = :mem\_cache\_store if  
RAILS\_ENV = ‘production’  
config.plugins = [“engines”,"\*"]  
end

require ‘memcache’

memcache\_options = {  
:c\_threshold =\> 10\_000,  
:compression =\> true,  
:debug =\> false,  
:namespace =\> “nef\_#{RAILS\_ENV}”,  
:readonly =\> false,  
:multithread =\> true  
:urlencode =\> false  
}

CACHE = MemCache.new memcache\_options  
CACHE.servers = ‘localhost:11211’

ActionController::Base.session\_options[:expires] = 1800  
ActionController::Base.session\_options[:cache] = CACHE

=====================

\<6 new client connection  
\<6 get nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1

> 6 sending key nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 6 END  
> \<6 set nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1 0 1800  
> 456  
> 6 STORED  
> \<6 get nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 6 sending key nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 6 END  
> \<6 set nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1 0 1800  
> 658  
> 6 STORED  
> \<6 get nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 6 sending key nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 6 END  
> \<6 set nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1 0 1800  
> 658  
> 6 STORED  
> \<7 new client connection  
> \<7 get nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 7 sending key nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1  
> 7 END  
> \<7 set nef\_production:session:d9ac0790bc2de7fc10924ac10794afb1 0 1800  
> 456

---

<div class="post-metadata">

**Author:** ![Chuck\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/87869e/32.png) [@Chuck\_V](https://www.ruby-forum.com/u/Chuck_V)\
**Post date:** [May 15, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/memcache-storage-failing-across-mongrels/91505/2 "2007-05-15T20:48:19Z")

</div>

Chuck, did you solved this?

---

<div class="post-metadata">

**Author:** ![Chuck\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/87869e/32.png) [@Chuck\_V](https://www.ruby-forum.com/u/Chuck_V)\
**Post date:** [May 15, 2007, 8:51pm UTC](https://www.ruby-forum.com/t/memcache-storage-failing-across-mongrels/91505/3 "2007-05-15T20:51:38Z")

</div>

dear sender,  
i´m out of the office until may 29th.  
your email will not be forwarded.  
for urgent stuff please contact removed\_email\_address@domain.invalid  
kind regards,  
alexander
