diff options
Diffstat (limited to 'lib/tasks/cache.rake')
-rw-r--r-- | lib/tasks/cache.rake | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake index 13365b9ec07..8c7e429ef24 100644 --- a/lib/tasks/cache.rake +++ b/lib/tasks/cache.rake @@ -7,24 +7,26 @@ namespace :cache do 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] + [Gitlab::Redis::Cache, Gitlab::Redis::RepositoryCache].each do |redis_instance| + redis_instance.with do |redis| + cache_key_pattern = %W[#{Gitlab::Redis::Cache::CACHE_NAMESPACE}* + projects/*/pipeline_status] - 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 - ) + 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::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do - redis.del(*keys) if keys.any? - end + Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do + Gitlab::Redis::ClusterUtil.batch_unlink(keys, redis) if keys.any? + end - break if cursor == REDIS_SCAN_START_STOP + break if cursor == REDIS_SCAN_START_STOP + end end end end |