Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-16 20:10:03 +0300
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-04 18:00:09 +0300
commit0163e27631fb993bd3541c09a95f0ef5e2026455 (patch)
treeb63cff41fe7d6e7433ecacfefd8be17e4fa29422 /lib/tasks/cache.rake
parentba7fcc9866588eb215fc69f5d8b73c77805e4eef (diff)
Add Gitlab::Redis connection pool
Diffstat (limited to 'lib/tasks/cache.rake')
-rw-r--r--lib/tasks/cache.rake25
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