diff options
author | José Valim <jose.valim@gmail.com> | 2010-07-18 11:01:32 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-18 11:02:08 +0200 |
commit | e210895ba95e498b9debbf43a3e5ae588bca81f0 (patch) | |
tree | 3031bf112cbfccf562a122a5e09b91ab07739aa3 /actionpack | |
parent | fa98eca75bd8666719bf3d061c87638850a20fe9 (diff) | |
download | rails-e210895ba95e498b9debbf43a3e5ae588bca81f0.tar.gz rails-e210895ba95e498b9debbf43a3e5ae588bca81f0.tar.bz2 rails-e210895ba95e498b9debbf43a3e5ae588bca81f0.zip |
Avoid uneeded queries in session stores if sid is not given.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/session/abstract_store.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb index 64f4d1d532..08c969c449 100644 --- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb @@ -191,8 +191,11 @@ module ActionDispatch def load_session(env) stale_session_check! do - sid = current_session_id(env) - sid, session = get_session(env, sid) + if sid = current_session_id(env) + sid, session = get_session(env, sid) + else + sid, session = generate_sid, {} + end [sid, session] end end diff --git a/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb b/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb index 28e3dbd732..5304440418 100644 --- a/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb @@ -25,7 +25,6 @@ module ActionDispatch private def get_session(env, sid) - sid ||= generate_sid begin session = @pool.get(sid) || {} rescue MemCache::MemCacheError, Errno::ECONNREFUSED |