Class Rack::Session::Memcache
In: lib/rack/session/memcache.rb
Parent: Abstract::ID

Rack::Session::Memcache provides simple cookie based session management. Session data is stored in memcached. The corresponding session key is maintained in the cookie. You may treat Session::Memcache as you would Session::Pool with the following caveats.

  • Setting :expire_after to 0 would note to the Memcache server to hang onto the session data until it would drop it according to it‘s own specifications. However, the cookie sent to the client would expire immediately.

Note that memcache does drop data before it may be listed to expire. For a full description of behaviour, please see memcache‘s documentation.

Methods

new  

Constants

DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge({ :namespace => 'rack:session', :memcache_server => 'localhost:11211'

Attributes

mutex  [R] 
pool  [R] 

Public Class methods

[Source]

    # File lib/rack/session/memcache.rb, line 29
29:       def initialize(app, options={})
30:         super
31:         @pool = MemCache.new @default_options[:memcache_server], @default_options
32:         unless @pool.servers.any?{|s|s.alive?}
33:           raise "#{self} unable to find server during initialization."
34:         end
35:         @mutex = Mutex.new
36:       end

[Validate]