Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cache the queries that are executed

  • Loading branch information...
commit 5c6c8dbc9d3180b76858619c44e9a32bca2ac3bb 1 parent 089f34b
@mattdbridges authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/transplant/planter.rb
View
6 lib/transplant/planter.rb
@@ -6,10 +6,14 @@ class Planter
def initialize(app_name, connection)
@app_name = app_name
@connection = connection
+ @queries ||= []
+ @results ||= {}
end
def query(sql)
- @connection.execute sql
+ return @results[sql] if @queries.include?(sql)
+ @queries << sql
+ @results[sql] = @connection.execute(sql)
end
def save(klass, other = {})
Please sign in to comment.
Something went wrong with that request. Please try again.