mirror of
https://github.com/discourse/discourse.git
synced 2026-08-13 14:35:08 -05:00
Added back the last_use timestamp to the AbstractAdapter
This was removed in https://github.com/rails/rails/commit/9e457a8654fa89fe329719f88ae3679aefb21e56
This commit is contained in:
@@ -1,6 +1,29 @@
|
||||
|
||||
if rails_master?
|
||||
class ActiveRecord::ConnectionAdapters::AbstractAdapter
|
||||
module LastUseExtension
|
||||
attr_reader :last_use
|
||||
|
||||
def initialize(connection, logger = nil, pool = nil)
|
||||
super
|
||||
@last_use = false
|
||||
end
|
||||
|
||||
def lease
|
||||
synchronize do
|
||||
unless in_use?
|
||||
@last_use = Time.now
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
prepend LastUseExtension
|
||||
end
|
||||
end
|
||||
|
||||
class ActiveRecord::ConnectionAdapters::ConnectionPool
|
||||
|
||||
# drain all idle connections
|
||||
# if idle_time is specified only connections idle for N seconds will be drained
|
||||
def drain(idle_time=nil)
|
||||
@@ -29,5 +52,4 @@ class ActiveRecord::ConnectionAdapters::ConnectionPool
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user