# Be sure to restart your server when you modify this file.

# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random, 
# no regular words or you'll be exposed to dictionary attacks.
ActionController::Base.session = {
  :key         => '_rails_app_session',
  :secret      => '208eeo6637s73f2597rerj909573f763c4u53zurquq066e1b6ho0xvmwilq118lblo823c0i6rg29c8i76xag9g686z8ds60t7w438930h6p5cer361sljyokzs9i01',
  :cookie_only => false
}

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
#ActionController::Base.session_store = :active_record_store
ActionController::Base.session_store = :mem_cache_store
ActionController::Base.session_options[:domain] = ".orbusneich.jp"

memcache_options = {
  :compression => false,
  :debug => false,
  :namespace => "mem-rails",
  :readonly => false,
  :urlencode => false
}
memcache_servers = ['192.168.0.2:11211', '192.168.0.5:11211']
CACHE = MemCache.new(memcache_options)
CACHE.servers = memcache_servers
ActionController::Base.session_options[:cache] = CACHE

if defined?(PhusionPassenger)
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
    if forked
      CACHE.reset
      if Rails.cache.class == ActiveSupport::Cache::MemCacheStore
        Rails.cache.instance_variable_get(:@data).reset
      end
    end
  end
end
