I've got a Rails 2.2.3 that I recently upgraded to 2.3.4.  I made a
new Rails tree and copied most of the stuff under "config" over (from
the new tree to my existing tree) in order to get things to a clean
2.3.x state.  Rails is frozen-in under "vendor" and "script/server"
verifies I'm running 2.3.4, so there's no old code lying around.

I decided to try out memcache-based sessions on my Rails app,
according to this URL:

http://awesomerails.wordpress.com/2008/06/26/memcache-sessions-in-rails/

I've got memcache-client installed, and my config/initializers/
session_store.rb looks like this:

require 'memcache'
CACHE = MemCache.new(:namespace => 'myprojectname')
CACHE.servers = 'localhost:11211'

ActionController::Base.session = {
  :session_key => '_myprojectname_session',
  :cache   => CACHE,
  :expires => 86400,
  :secret  => '128-random-characters'
}
ActionController::Base.session_store = :mem_cache_store

Now, sessions work fine.  The only trouble is, my application doesn't
yet touch the session in any conceivable way -- and yet, according to
my memcached logs, I'm getting sessions fetched and stored with every
single request.  This runs contrary to the claims in the 2.3.x
changelogs, which say that sessions are lazy-loaded and only loaded/
stored when accessed now.

I've tried multiple environments in case it was specific to one of
them:  WEBrick, Thin, FastCGI.  All the same behaviour.

Since I only plan to use sessions for a small part of the application,
this is rather sub-optimal, not least because anyone who disables
cookies (including myself, typically) is going to be spamming my
session store with a new session every request.

I realise I can just disable sessions for controllers I don't want,
but while there are only a few parts of the app that will write to the
session, there are several that will want to read it (if available).
Plus, disabling sessions per controller is deprecated because it's
supposedly unnecessary these days (due to lazy loading), isn't it?
That's the main reason I bothered to upgrade in the first place.

Am I missing something here, or is lazy loading just not implemented
for memcached sessions?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to