diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-14 20:46:06 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-14 20:46:06 +0000 |
commit | d0df7f2b12b201edbef0d59360224e68f9a0a447 (patch) | |
tree | e3238329134b3320ab1904b8d054c3a334405acc /actionpack/lib/action_controller/session/mem_cache_store.rb | |
parent | a0bcb45b095a38f8e2959ca7d87dc7449b567ab8 (diff) | |
download | rails-d0df7f2b12b201edbef0d59360224e68f9a0a447.tar.gz rails-d0df7f2b12b201edbef0d59360224e68f9a0a447.tar.bz2 rails-d0df7f2b12b201edbef0d59360224e68f9a0a447.zip |
Memcached sessions: add session data on initialization; don't silently discard exceptions; add unit tests. Closes #9823.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7885 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/session/mem_cache_store.rb')
-rw-r--r-- | actionpack/lib/action_controller/session/mem_cache_store.rb | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/actionpack/lib/action_controller/session/mem_cache_store.rb b/actionpack/lib/action_controller/session/mem_cache_store.rb index 6fd3ed7c7b..2f08af663d 100644 --- a/actionpack/lib/action_controller/session/mem_cache_store.rb +++ b/actionpack/lib/action_controller/session/mem_cache_store.rb @@ -57,26 +57,22 @@ begin @expires = options['expires'] || 0 @session_key = "session:#{id}" @session_data = {} + # Add this key to the store if haven't done so yet + unless @cache.get(@session_key) + @cache.add(@session_key, @session_data, @expires) + end end # Restore session state from the session's memcache entry. # # Returns the session state as a hash. def restore - begin - @session_data = @cache[@session_key] || {} - rescue - @session_data = {} - end + @session_data = @cache[@session_key] || {} end # Save session state to the session's memcache entry. def update - begin - @cache.set(@session_key, @session_data, @expires) - rescue - # Ignore session update failures. - end + @cache.set(@session_key, @session_data, @expires) end # Update and close the session's memcache entry. @@ -86,17 +82,14 @@ begin # Delete the session's memcache entry. def delete - begin - @cache.delete(@session_key) - rescue - # Ignore session delete failures. - end + @cache.delete(@session_key) @session_data = {} end def data @session_data end + end end end |