summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-11-11 16:28:31 +0100
committerDouwe Maan <douwe@gitlab.com>2015-11-18 12:02:08 +0100
commitb1f4d14f7d521b1ceb167a52a188eb93e9384db4 (patch)
tree1587df0932c733d723c577b5fc66f230014b5fea
parent153085a93bf7f2350d15009fe7924cea190cd7f2 (diff)
downloadgitlab-ce-b1f4d14f7d521b1ceb167a52a188eb93e9384db4.tar.gz
Clean up Repository cache code.
-rw-r--r--app/models/repository.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index c5b6ee80dc6..fd60c7edbb1 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -105,29 +105,25 @@ class Repository
end
def add_branch(branch_name, ref)
- cache.expire(:branch_names)
- @branches = nil
+ expire_branches_cache
gitlab_shell.add_branch(path_with_namespace, branch_name, ref)
end
def add_tag(tag_name, ref, message = nil)
- cache.expire(:tag_names)
- @tags = nil
+ expire_tags_cache
gitlab_shell.add_tag(path_with_namespace, tag_name, ref, message)
end
def rm_branch(branch_name)
- cache.expire(:branch_names)
- @branches = nil
+ expire_branches_cache
gitlab_shell.rm_branch(path_with_namespace, branch_name)
end
def rm_tag(tag_name)
- cache.expire(:tag_names)
- @tags = nil
+ expire_tags_cache
gitlab_shell.rm_tag(path_with_namespace, tag_name)
end
@@ -169,6 +165,16 @@ class Repository
end
end
+ def expire_tags_cache
+ cache.expire(:tag_names)
+ @tags = nil
+ end
+
+ def expire_branches_cache
+ cache.expire(:branch_names)
+ @branches = nil
+ end
+
def expire_cache
cache_keys.each do |key|
cache.expire(key)