mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-06 14:58:27 +00:00
22 lines
No EOL
534 B
Ruby
22 lines
No EOL
534 B
Ruby
module DatasourceUtils
|
|
extend ActiveSupport::Concern
|
|
|
|
def get_cached_connection(data_source)
|
|
|
|
connection = nil
|
|
if $connections.include? data_source.id
|
|
data = $connections[data_source.id]
|
|
if data[:updated_at] === data_source.updated_at
|
|
connection = $connections[data_source.id][:connection]
|
|
end
|
|
end
|
|
|
|
connection
|
|
end
|
|
|
|
def cache_connection(data_source, connection)
|
|
$connections[data_source.id] = { connection: connection, updated_at: data_source.updated_at }
|
|
end
|
|
|
|
end
|
|
|