diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-03 21:11:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-03 21:11:16 +0300 |
commit | 9578c9f9e88421a5dc4d9215f40d932bd30cbabc (patch) | |
tree | 51cc56403430f901de45cb82a6ab5f63c1f37712 /lib/tasks | |
parent | 7fcda12793acc54ba8de037f50cc3696dbd0f002 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/cache.rake | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake index 4d698e56444..46d940255de 100644 --- a/lib/tasks/cache.rake +++ b/lib/tasks/cache.rake @@ -2,32 +2,22 @@ namespace :cache do namespace :clear do - REDIS_CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000 - REDIS_SCAN_START_STOP = '0'.freeze # Magic value, see http://redis.io/commands/scan - desc "GitLab | Cache | Clear redis cache" task redis: :environment do - Gitlab::Redis::Cache.with do |redis| - cache_key_pattern = %W[#{Gitlab::Redis::Cache::CACHE_NAMESPACE}* - projects/*/pipeline_status] + cache_key_patterns = %W[ + #{Gitlab::Redis::Cache::CACHE_NAMESPACE}* + #{Gitlab::Cache::Ci::ProjectPipelineStatus::ALL_PIPELINES_STATUS_PATTERN} + ] - 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 - ) + ::Gitlab::Cleanup::Redis::BatchDeleteByPattern.new(cache_key_patterns).execute + end - Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do - redis.del(*keys) if keys.any? - end + desc "GitLab | Cache | Clear description templates redis cache" + task description_templates: :environment do + project_ids = Array(ENV['project_ids']&.split(',')).map!(&:squish) - break if cursor == REDIS_SCAN_START_STOP - end - end - end + cache_key_patterns = ::Gitlab::Cleanup::Redis::DescriptionTemplatesCacheKeysPatternBuilder.new(project_ids).execute + ::Gitlab::Cleanup::Redis::BatchDeleteByPattern.new(cache_key_patterns).execute end task all: [:redis] |