Cache lookup results into hash to prevent repeating same requests to git repo

This commit is contained in:
Dmitriy Zaporozhets 2015-03-21 13:44:51 -07:00
parent 2c796a1785
commit c378d20c84
1 changed files with 10 additions and 1 deletions

View File

@ -184,8 +184,17 @@ class Repository
end
end
def lookup_cache
@lookup_cache ||= {}
end
def method_missing(m, *args, &block)
raw_repository.send(m, *args, &block)
if m == :lookup && !block_given?
lookup_cache[m] ||= {}
lookup_cache[m][args.join(":")] ||= raw_repository.send(m, *args, &block)
else
raw_repository.send(m, *args, &block)
end
end
def respond_to?(method)