Changeset 3465
- Timestamp:
- 01/22/06 22:21:26 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/session/mem_cache_store.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3462 r3465 1 1 *SVN* 2 3 * Added the possibility to specify atomatic expiration for the memcachd session container #3571 [Stefan Kaes] 2 4 3 5 * Change layout discovery to take into account the change in semantics with File.join and nil arguments. [Marcel Molina Jr.] trunk/actionpack/lib/action_controller/session/mem_cache_store.rb
r525 r3465 26 26 # Create a new CGI::Session::MemCache instance 27 27 # 28 # This constructor is used internally by CGI::Session. The28 # This constructor is used internally by CGI::Session. The 29 29 # user does not generally need to call it directly. 30 30 # 31 31 # +session+ is the session for which this instance is being 32 # created. The session id must only contain alphanumeric32 # created. The session id must only contain alphanumeric 33 33 # characters; automatically generated session ids observe 34 34 # this requirement. 35 35 # 36 # +option + is a hash of options for the initializer.The36 # +options+ is a hash of options for the initializer. The 37 37 # following options are recognized: 38 38 # 39 39 # cache:: an instance of a MemCache client to use as the 40 40 # session cache. 41 # 42 # expires:: an expiry time value to use for session entries in 43 # the session cache. +expires+ is interpreted in seconds 44 # relative to the current time if itÂ’s less than 60*60*24*30 45 # (30 days), or as an absolute Unix time (e.g., Time#to_i) if 46 # greater. If +expires+ is +0+, or not passed on +options+, 47 # the entry will never expire. 41 48 # 42 49 # This session's memcache entry will be created if it does … … 46 53 unless check_id(id) 47 54 raise ArgumentError, "session_id '%s' is invalid" % id 48 end55 end 49 56 @cache = options['cache'] || MemCache.new('localhost') 50 @session_key = "session:#{id}" 51 @hash = {} 57 @expires = options['expires'] || 0 58 @session_key = "session:#{id}" 59 @session_data = {} 52 60 end 53 61 … … 57 65 def restore 58 66 begin 59 @ hash = @cache[@session_key]67 @session_data = @cache[@session_key] || {} 60 68 rescue 61 # Ignore session get failures.69 @session_data = {} 62 70 end 63 @hash = {} unless @hash64 @hash65 71 end 66 72 … … 68 74 def update 69 75 begin 70 @cache [@session_key] = @hash76 @cache.set(@session_key, @session_data, @expires) 71 77 rescue 72 78 # Ignore session update failures. … … 86 92 # Ignore session delete failures. 87 93 end 88 @hash= {}94 @session_data = {} 89 95 end 90 96 end