Class: DeviseCasAuthenticatable::MemcacheChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/devise_cas_authenticatable/memcache_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rails_configuration) ⇒ MemcacheChecker

Returns a new instance of MemcacheChecker.



7
8
9
# File 'lib/devise_cas_authenticatable/memcache_checker.rb', line 7

def initialize(rails_configuration)
  @rails_configuration = rails_configuration
end

Instance Attribute Details

#rails_configurationObject (readonly)

Returns the value of attribute rails_configuration.



5
6
7
# File 'lib/devise_cas_authenticatable/memcache_checker.rb', line 5

def rails_configuration
  @rails_configuration
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/devise_cas_authenticatable/memcache_checker.rb', line 15

def alive?
  memcache_servers = rails_configuration.session_options[:memcache_server] || ["127.0.0.1:11211"]
  memcache_servers.each do |server|
    host, port = server.split(":")
    begin
      Net::Telnet.new("Host" => host, "Port" => port, "Timeout" => 1)
      return true
    rescue Errno::ECONNREFUSED
      return false
    end
  end
end

#session_store_memcache?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/devise_cas_authenticatable/memcache_checker.rb', line 11

def session_store_memcache?
  !!(session_store_class.name =~ /memcache/i)
end