1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Use mget in History instead of making many roundtrips.

This commit is contained in:
Jonathan Hyman 2014-03-22 00:28:27 -04:00
parent e01675980d
commit d0d94e876a

View file

@ -68,15 +68,19 @@ module Sidekiq
def date_stat_hash(stat)
i = 0
stat_hash = {}
keys = []
dates = []
while i < @days_previous
date = @start_date - i
keys << "stat:#{stat}:#{date}"
dates << date
i += 1
end
Sidekiq.redis do |conn|
while i < @days_previous
date = @start_date - i
value = conn.get("stat:#{stat}:#{date}")
stat_hash[date.to_s] = value ? value.to_i : 0
i += 1
conn.mget(keys).each_with_index do |value, i|
stat_hash[dates[i].to_s] = value ? value.to_i : 0
end
end