Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-10-25 20:55:19 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-10-25 20:57:08 +0300
commitdd2e91cc7832db66615a466956e6c8aa0cd0fba0 (patch)
treef0cc894e180e0c9857221726a7c86c2a315970a5 /lib/gitlab/cache
parent982276c3f7d52c0acbd889fd7c38b0990f580455 (diff)
Cache pipeline status only for specific sha
Diffstat (limited to 'lib/gitlab/cache')
-rw-r--r--lib/gitlab/cache/ci/project_pipeline_status.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/gitlab/cache/ci/project_pipeline_status.rb b/lib/gitlab/cache/ci/project_pipeline_status.rb
index b369b9e7600..99fe7d3a252 100644
--- a/lib/gitlab/cache/ci/project_pipeline_status.rb
+++ b/lib/gitlab/cache/ci/project_pipeline_status.rb
@@ -41,8 +41,8 @@ module Gitlab
end
end
- def self.cache_key_for_project(project)
- "#{Gitlab::Redis::Cache::CACHE_NAMESPACE}:projects/#{project.id}/pipeline_status"
+ def self.cache_key_for_project(project, cache_sha = project.commit&.sha)
+ "#{Gitlab::Redis::Cache::CACHE_NAMESPACE}:projects/#{project.id}/pipeline_status/#{cache_sha}"
end
def self.update_for_pipeline(pipeline)
@@ -84,9 +84,7 @@ module Gitlab
def load_from_project
return unless commit
- self.sha = commit.sha
- self.status = commit.status
- self.ref = project.default_branch
+ self.sha, self.status, self.ref = commit.sha, commit.status, project.default_branch
end
# We only cache the status for the HEAD commit of a project
@@ -104,6 +102,8 @@ module Gitlab
def load_from_cache
Gitlab::Redis::Cache.with do |redis|
self.sha, self.status, self.ref = redis.hmget(cache_key, :sha, :status, :ref)
+
+ self.status = nil if self.status.empty?
end
end