diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-21 23:44:51 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-21 23:44:51 +0300 |
commit | c378d20c8440aff83a8bd54c5aed9f06a9c205f8 (patch) | |
tree | 80d6040665b0be5d1311a6c990099ff5178134f8 /app | |
parent | 2c796a1785242a6940ef3b7ef8a06fa8617ec245 (diff) |
Cache lookup results into hash to prevent repeating same requests to git repo
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 2e3cfb85594..7b8a34eba2c 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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) |