diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-04-16 07:27:09 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-04-16 07:27:09 +0000 |
commit | a6a1b7310f240ea037212dd97690e99b35ddc06e (patch) | |
tree | 036294dbe2e12d9920f065523e18e8542d5ba9e4 /lib | |
parent | ef3fb77f0fd108d0e66d8ea63efd15e0af49b3eb (diff) | |
parent | 4b30aec0aa9e52d3d7d4394f05a725d14e0c0db3 (diff) | |
download | gitlab-ce-a6a1b7310f240ea037212dd97690e99b35ddc06e.tar.gz |
Merge branch '44582-clear-pipeline-status-cache' into 'master'
Allow `rake cache:clear` clearing pipeline status cache
Closes #44582
See merge request gitlab-org/gitlab-ce!18257
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/cache/ci/project_pipeline_status.rb | 2 | ||||
-rw-r--r-- | lib/tasks/cache.rake | 23 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/gitlab/cache/ci/project_pipeline_status.rb b/lib/gitlab/cache/ci/project_pipeline_status.rb index dba37892863..add048d671e 100644 --- a/lib/gitlab/cache/ci/project_pipeline_status.rb +++ b/lib/gitlab/cache/ci/project_pipeline_status.rb @@ -40,7 +40,7 @@ module Gitlab end def self.cache_key_for_project(project) - "projects/#{project.id}/pipeline_status" + "#{Gitlab::Redis::Cache::CACHE_NAMESPACE}:projects/#{project.id}/pipeline_status" end def self.update_for_pipeline(pipeline) diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake index 564aa141952..cb4d5abffbc 100644 --- a/lib/tasks/cache.rake +++ b/lib/tasks/cache.rake @@ -6,17 +6,22 @@ namespace :cache do desc "GitLab | Clear redis cache" task redis: :environment do Gitlab::Redis::Cache.with do |redis| - cursor = REDIS_SCAN_START_STOP - loop do - cursor, keys = redis.scan( - cursor, - match: "#{Gitlab::Redis::Cache::CACHE_NAMESPACE}*", - count: REDIS_CLEAR_BATCH_SIZE - ) + cache_key_pattern = %W[#{Gitlab::Redis::Cache::CACHE_NAMESPACE}* + projects/*/pipeline_status] - redis.del(*keys) if keys.any? + cache_key_pattern.each do |match| + cursor = REDIS_SCAN_START_STOP + loop do + cursor, keys = redis.scan( + cursor, + match: match, + count: REDIS_CLEAR_BATCH_SIZE + ) - break if cursor == REDIS_SCAN_START_STOP + redis.del(*keys) if keys.any? + + break if cursor == REDIS_SCAN_START_STOP + end end end end |