Cache lookup results into hash to prevent repeating same requests to git repo
This commit is contained in:
parent
2c796a1785
commit
c378d20c84
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue