module AdvancedConnection::ActiveRecordExt::AbstractAdapter
Public Instance Methods
<=>(other)
click to toggle source
# File lib/advanced_connection/active_record_ext/abstract_adapter.rb, line 65 def <=>(other) case pool.queue_type when :prefer_younger then # when prefering younger, we sort oldest->youngest # to ensure that older connections will be reaped # during #remove_idle_connections() -(instance_age <=> other.instance_age) when :prefer_older then # when prefering older, we sort youngest->oldest to # ensure that younger connections will be reaped # during #remove_idle_connections() (instance_age <=> other.instance_age) else # With fifo / lifo queues, we only care about the # last time a given connection was used (inferred # by when it was last checked into the pool). # This ensures that the longer idling connections # will be reaped. -(last_checked_in <=> other.last_checked_in) end end
idle?()
click to toggle source
# File lib/advanced_connection/active_record_ext/abstract_adapter.rb, line 61 def idle? idle_time > pool.max_idle_time end
idle_time()
click to toggle source
# File lib/advanced_connection/active_record_ext/abstract_adapter.rb, line 57 def idle_time (in_use? ? 0.0 : Time.now - @last_checked_in).to_f end
initialize_with_advanced_connection(*args, &block)
click to toggle source
# File lib/advanced_connection/active_record_ext/abstract_adapter.rb, line 39 def initialize_with_advanced_connection(*args, &block) @instantiated_at = Time.now @last_checked_in = @instantiated_at @last_checked_out = false initialize_without_advanced_connection(*args, &block) end
instance_age()
click to toggle source
# File lib/advanced_connection/active_record_ext/abstract_adapter.rb, line 53 def instance_age (Time.now - @instantiated_at).to_f end
lease_with_advanced_connection()
click to toggle source
# File lib/advanced_connection/active_record_ext/abstract_adapter.rb, line 46 def lease_with_advanced_connection synchronize { @last_checked_out = Time.now lease_without_advanced_connection } end