mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 13:24:52 +08:00
a48af2f120
Plus small DB related fixes
28 lines
469 B
Ruby
28 lines
469 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "lru_redux"
|
|
|
|
module Migrations::Database
|
|
class PreparedStatementCache < LruRedux::Cache
|
|
class PreparedStatementHash < Hash
|
|
def shift
|
|
result = super
|
|
if (stmt = result[1])
|
|
stmt.close
|
|
end
|
|
result
|
|
end
|
|
|
|
def clear
|
|
each_value(&:close)
|
|
super
|
|
end
|
|
end
|
|
|
|
def initialize(*args)
|
|
super
|
|
@data = PreparedStatementHash.new
|
|
end
|
|
end
|
|
end
|