How to use mem_cache_store?


#1

Hi,

I’m trying to use mem_cache_store for sessions. I have installed the
server and the gem and have added the following to my
config/environment.rb:

memcache_options = {
:c_threshold => 10_000,
:compression => true,
:debug => false,
:namespace => ‘ruby-forum.com’,
:readonly => false,
:urlencode => false
}

CACHE = MemCache.new memcache_options
CACHE.servers = ‘localhost:11211’

session_options = {
:database_manager => CGI::Session::MemCacheStore,
:cache => CACHE,
:session_domain => ‘ruby-forum.com
}

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update
session_options
<<<<<<<<<<<<<<<<<<<<<<<<<

Bur Rails still uses the session table in the database. Is there
anything else I have to do to in order to make this work?

Thanks
Andreas


#2

Andreas S. wrote:

Bur Rails still uses the session table in the database. Is there
anything else I have to do to in order to make this work?

Stupid. I had a manual setting for ActiveRecordStore somewhere else in
my app.

That’s all it needs to use MemCacheStore:
config.action_controller.session_store = :mem_cache_store