Commit f7f6acee0b5beab61ea6d3e7996ce93fd0a4b22f
1 parent
e36c0c14
Exists in
master
and in
4 other branches
Lets cache branch_names, tag_names for repo
Showing
1 changed file
with
14 additions
and
0 deletions
Show diff stats
app/models/repository.rb
... | ... | @@ -33,6 +33,18 @@ class Repository |
33 | 33 | commits |
34 | 34 | end |
35 | 35 | |
36 | + def branch_names | |
37 | + Rails.cache.fetch(cache_key(:branch_names)) do | |
38 | + raw_repository.branch_names | |
39 | + end | |
40 | + end | |
41 | + | |
42 | + def tag_names | |
43 | + Rails.cache.fetch(cache_key(:tag_names)) do | |
44 | + raw_repository.tag_names | |
45 | + end | |
46 | + end | |
47 | + | |
36 | 48 | def method_missing(m, *args, &block) |
37 | 49 | raw_repository.send(m, *args, &block) |
38 | 50 | end |
... | ... | @@ -47,6 +59,8 @@ class Repository |
47 | 59 | |
48 | 60 | def expire_cache |
49 | 61 | Rails.cache.delete(cache_key(:size)) |
62 | + Rails.cache.delete(cache_key(:branch_names)) | |
63 | + Rails.cache.delete(cache_key(:tag_names)) | |
50 | 64 | end |
51 | 65 | |
52 | 66 | def cache_key(type) | ... | ... |