Skip to content
Snippets Groups Projects
Commit f7f6acee authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Lets cache branch_names, tag_names for repo

parent e36c0c14
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -33,6 +33,18 @@ class Repository
commits
end
 
def branch_names
Rails.cache.fetch(cache_key(:branch_names)) do
raw_repository.branch_names
end
end
def tag_names
Rails.cache.fetch(cache_key(:tag_names)) do
raw_repository.tag_names
end
end
def method_missing(m, *args, &block)
raw_repository.send(m, *args, &block)
end
Loading
Loading
@@ -47,6 +59,8 @@ class Repository
 
def expire_cache
Rails.cache.delete(cache_key(:size))
Rails.cache.delete(cache_key(:branch_names))
Rails.cache.delete(cache_key(:tag_names))
end
 
def cache_key(type)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment