Skip to content
代码片段 群组 项目
提交 f7f6acee 编辑于 作者: Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
浏览文件

Lets cache branch_names, tag_names for repo

上级 e36c0c14
No related branches found
No related tags found
无相关合并请求
...@@ -33,6 +33,18 @@ def commits_between(target, source) ...@@ -33,6 +33,18 @@ def commits_between(target, source)
commits commits
end 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) def method_missing(m, *args, &block)
raw_repository.send(m, *args, &block) raw_repository.send(m, *args, &block)
end end
...@@ -47,6 +59,8 @@ def size ...@@ -47,6 +59,8 @@ def size
def expire_cache def expire_cache
Rails.cache.delete(cache_key(:size)) Rails.cache.delete(cache_key(:size))
Rails.cache.delete(cache_key(:branch_names))
Rails.cache.delete(cache_key(:tag_names))
end end
def cache_key(type) def cache_key(type)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册