Skip to content

Commit

Permalink
Avoid uneeded queries in session stores if sid is not given.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 18, 2010
1 parent fa98eca commit e210895
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Expand Up @@ -191,8 +191,11 @@ def set_cookie(request, options)

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
Expand Down
Expand Up @@ -25,7 +25,6 @@ def initialize(app, options = {})

private
def get_session(env, sid)
sid ||= generate_sid
begin
session = @pool.get(sid) || {}
rescue MemCache::MemCacheError, Errno::ECONNREFUSED
Expand Down
1 change: 0 additions & 1 deletion activerecord/lib/active_record/session_store.rb
Expand Up @@ -294,7 +294,6 @@ def destroy
private
def get_session(env, sid)
Base.silence do
sid ||= generate_sid
session = find_session(sid)
env[SESSION_RECORD_KEY] = session
[sid, session.data]
Expand Down

0 comments on commit e210895

Please sign in to comment.