Class: MemCachedSessionStore

Inherits:
ActionController::Session::AbstractStore
  • Object
show all
Defined in:
lib/mem_cached_session_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ MemCachedSessionStore

Returns a new instance of MemCachedSessionStore.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mem_cached_session_store.rb', line 5

def initialize(app, options = {})
  # Support old :expires option
  options[:expire_after] ||= options[:expires]

  super

  @default_options = {
    :namespace => 'rack:session',
    :servers => 'localhost:11211'
  }.merge(@default_options)

  @default_options[:prefix_key] ||= @default_options[:namespace]

  @pool = options[:cache] || Memcached.new(@default_options[:servers], @default_options)
  # unless @pool.servers.any? { |s| s.alive? }
  #   raise "#{self} unable to find server during initialization."
  # end
  @mutex = Mutex.new

  super
end