跳到內容 跳到搜尋

Active Record 連線池 Reaper

每隔 frequency 秒,reaper 將在 pool 上呼叫 reapflush。一個以零頻率實例化的 reaper 永遠不會清除連線池。

透過在資料庫 YAML 檔案中設定 reaping_frequency 來設定頻率(預設值為 60 秒)。

方法
N
R

屬性

[R] frequency
[R] pool

類別公開方法

new(pool, frequency)

# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb, line 19
def initialize(pool, frequency)
  @pool      = pool
  @frequency = frequency
end

實例公開方法

run()

# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb, line 71
def run
  return unless frequency && frequency > 0
  self.class.register_pool(pool, frequency)
end