diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2016-03-16 20:10:03 +0300 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2016-04-04 18:00:09 +0300 |
commit | 0163e27631fb993bd3541c09a95f0ef5e2026455 (patch) | |
tree | b63cff41fe7d6e7433ecacfefd8be17e4fa29422 /lib/tasks | |
parent | ba7fcc9866588eb215fc69f5d8b73c77805e4eef (diff) |
Add Gitlab::Redis connection pool
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/cache.rake | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake index 51e746ef923..6c2e2e91494 100644 --- a/lib/tasks/cache.rake +++ b/lib/tasks/cache.rake @@ -4,18 +4,19 @@ namespace :cache do desc "GitLab | Clear redis cache" task :clear => :environment do - redis = Redis.new(url: Gitlab::RedisConfig.url) - cursor = REDIS_SCAN_START_STOP - loop do - cursor, keys = redis.scan( - cursor, - match: "#{Gitlab::REDIS_CACHE_NAMESPACE}*", - count: CLEAR_BATCH_SIZE - ) - - redis.del(*keys) if keys.any? - - break if cursor == REDIS_SCAN_START_STOP + Gitlab::Redis.with do |redis| + cursor = REDIS_SCAN_START_STOP + loop do + cursor, keys = redis.scan( + cursor, + match: "#{Gitlab::REDIS_CACHE_NAMESPACE}*", + count: CLEAR_BATCH_SIZE + ) + + redis.del(*keys) if keys.any? + + break if cursor == REDIS_SCAN_START_STOP + end end end end |