# :mem\_cache\_store and memcache-client for session

**URL:** <https://www.ruby-forum.com/t/mem-cache-store-and-memcache-client-for-session/188199>\
**Category:** Rails\
**Created:** [July 11, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/mem-cache-store-and-memcache-client-for-session/188199 "2007-07-11T17:24:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/58f4c7/32.png) [@sharkie](https://www.ruby-forum.com/u/sharkie)\
**Post date:** [July 11, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/mem-cache-store-and-memcache-client-for-session/188199/1 "2007-07-11T17:24:51Z")

</div>

Seems to not be working in that there is no error, but my Rails app is  
not keeping track of any session. Fragment cache is working, however. I  
have tried many different ways, but just can’t get this to work. My  
memcached-vv also looks normal. Can someone please help me, or tell me  
where to start looking.

evironment.rb:

require File.join(File.dirname( **FILE** ), ‘boot’)  
require\_gem ‘memcache-client’

memcache\_options = {  
:compression =\> false,  
:debug =\> false,  
:namespace =\> ‘domain’,  
:readonly =\> false,  
:urlencode =\> false  
}  
memcache\_servers = “localhost:11211”

Rails::Initializer.run do |config|  
config.action\_controller.session\_store = :mem\_cache\_store  
config.action\_controller.fragment\_cache\_store = :mem\_cache\_store,  
memcache\_servers, memcache\_options  
#config.action\_controller.fragment\_cache\_store = CACHE, {}  
#ActionController::CgiRequest::DEFAULT\_SESSION\_OPTIONS.merge!({  
‘cache’ =\> CACHE })

require ‘hodel\_3000\_compliant\_logger’  
config.logger = Hodel3000CompliantLogger.new(config.log\_path)  
end

cache\_params = \*([memcache\_servers, memcache\_options].flatten)  
CACHE = MemCache.new \*cache\_params  
ActionController::CgiRequest::DEFAULT\_SESSION\_OPTIONS.merge!({ ‘cache’  
=\> CACHE })

ActionMailer::Base.delivery\_method = :smtp

ActionMailer::Base.server\_settings = {  
:address =\> “[mail.domain.com](http://mail.domain.com)”,  
:port =\> 25,  
:domain =\> “[domain.com](http://domain.com)”,  
}

ActionMailer::Base.perform\_deliveries = true  
ActionMailer::Base.raise\_delivery\_errors = true  
ActionMailer::Base.default\_charset = “utf-8”

require ‘RMagick’  
include Magick  
require ‘cgi’  
require ‘cached\_model’  
require ‘misc’

---

<div class="post-metadata">

**Author:** ![sharkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/58f4c7/32.png) [@sharkie](https://www.ruby-forum.com/u/sharkie)\
**Post date:** [July 11, 2007, 6:22pm UTC](https://www.ruby-forum.com/t/mem-cache-store-and-memcache-client-for-session/188199/2 "2007-07-11T18:22:17Z")

</div>

I am suspecting that my session breaks when I place a model into the  
session.

Example: session[:user] = @user

where @user is a Rails model.

Is this to be expected?
