Class: ActionDispatch::Session::MemCacheStore

Inherits:
AbstractStore show all
Defined in:
lib/action_dispatch/middleware/session/mem_cache_store.rb

Constant Summary

Constants inherited from AbstractStore

AbstractStore::DEFAULT_OPTIONS, AbstractStore::ENV_SESSION_KEY, AbstractStore::ENV_SESSION_OPTIONS_KEY

Instance Method Summary collapse

Methods inherited from AbstractStore

#call

Constructor Details

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

Returns a new instance of MemCacheStore.



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

def initialize(app, options = {})
  require 'memcache'

  # Support old :expires option
  options[:expire_after] ||= options[:expires]

  super

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

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

  super
end