Class: DeviseCasAuthenticatable::MemcacheChecker
- Inherits:
-
Object
- Object
- DeviseCasAuthenticatable::MemcacheChecker
- Defined in:
- lib/devise_cas_authenticatable/memcache_checker.rb
Instance Attribute Summary collapse
-
#rails_configuration ⇒ Object
readonly
Returns the value of attribute rails_configuration.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(rails_configuration) ⇒ MemcacheChecker
constructor
A new instance of MemcacheChecker.
- #session_store_memcache? ⇒ Boolean
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_configuration ⇒ Object (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
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.[: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
11 12 13 |
# File 'lib/devise_cas_authenticatable/memcache_checker.rb', line 11 def session_store_memcache? !!(session_store_class.name =~ /memcache/i) end |