diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-04-09 20:41:55 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-04-10 20:57:00 +0800 |
commit | 4b30aec0aa9e52d3d7d4394f05a725d14e0c0db3 (patch) | |
tree | 7fc3713103151a70d08404fa0b48a49b25dfa026 /lib/tasks/cache.rake | |
parent | de36ca81d35992c265cd4fd09c774cb793dbd246 (diff) | |
download | gitlab-ce-44582-clear-pipeline-status-cache.tar.gz |
Allow `rake cache:clear` clearing pipeline status cache44582-clear-pipeline-status-cache
* Use the correct key prefix
* Clear old cache keys
TODO:
At some point we could remove clearing old cache keys.
Diffstat (limited to 'lib/tasks/cache.rake')
-rw-r--r-- | lib/tasks/cache.rake | 23 |
1 files changed, 14 insertions, 9 deletions
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 |