mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 23:33:45 +08:00
Added back the last_use
timestamp to the AbstractAdapter
This was removed in 9e457a8654
This commit is contained in:
parent
bddaf8193a
commit
4d188ca5b0
|
@ -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
|
class ActiveRecord::ConnectionAdapters::ConnectionPool
|
||||||
|
|
||||||
# drain all idle connections
|
# drain all idle connections
|
||||||
# if idle_time is specified only connections idle for N seconds will be drained
|
# if idle_time is specified only connections idle for N seconds will be drained
|
||||||
def drain(idle_time=nil)
|
def drain(idle_time=nil)
|
||||||
|
@ -29,5 +52,4 @@ class ActiveRecord::ConnectionAdapters::ConnectionPool
|
||||||
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user