Module: Motor::Resources::CustomSqlColumnsCache

Defined in:
lib/motor/resources/custom_sql_columns_cache.rb

Constant Summary collapse

CACHE_STORE =
ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes)

Class Method Summary collapse

Class Method Details

.call(sql) ⇒ Object


10
11
12
13
14
# File 'lib/motor/resources/custom_sql_columns_cache.rb', line 10

def call(sql)
  CACHE_STORE.fetch(sql.hash) do
    Queries::RunQuery.call(Query.new(sql_body: sql), limit: 0).columns || []
  end
end