# Memcache configuration for sessions

**URL:** <https://www.ruby-forum.com/t/memcache-configuration-for-sessions/184981>\
**Category:** Rails\
**Created:** [March 11, 2010, 12:15pm UTC](https://www.ruby-forum.com/t/memcache-configuration-for-sessions/184981 "2010-03-11T12:15:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcin\_Seroczynski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@Marcin\_Seroczynski](https://www.ruby-forum.com/u/Marcin_Seroczynski)\
**Post date:** [March 11, 2010, 12:15pm UTC](https://www.ruby-forum.com/t/memcache-configuration-for-sessions/184981/1 "2010-03-11T12:15:29Z")

</div>

Hello,

I’ve already got memcached running on desired machine by this command:  
memcached -d -m 256 -u nobody -p 11211

My configuration is placed in /config/enviroments/production.rb  
[http://pastie.org/863178](http://pastie.org/863178)

But still memcache session store uses default configuration which is  
described in API Class:  
ActionController::Session::MemCacheStore  
([http://railsapi.com/doc/rails-v2.3.5/classes/ActionController/Session/](http://railsapi.com/doc/rails-v2.3.5/classes/ActionController/Session/)  
MemCacheStore.html - check source and @default\_options, lines 13-16)

Could anyone tell me how to properly pass those configuration for  
memcache sessions?

Best,  
Martin

---

<div class="post-metadata">

**Author:** ![Marcin\_Seroczynski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@Marcin\_Seroczynski](https://www.ruby-forum.com/u/Marcin_Seroczynski)\
**Post date:** [March 11, 2010, 12:15pm UTC](https://www.ruby-forum.com/t/memcache-configuration-for-sessions/184981/2 "2010-03-11T12:15:29Z")

</div>

Hello,

I have found an solution and wanted to share:  
[http://pastie.org/864771](http://pastie.org/864771)

Now my question is… why do I have to declare a new MemCache object  
to pass it to sessions?  
Why rails by default don’t uses already configured memcache object  
from:  
config.action\_controller.session\_store = :mem\_cache\_store

We should be able to do something like this:  
config.action\_controller.session\_store = :mem\_cache\_store, “localhost:  
11212”

Any ideas?

Best,  
Martin
